Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3b7a305
fixing issue #10181: don't call setInstantiable(...) for class still …
axeluhl Nov 25, 2025
9f02515
issue-10181: working towards a test case for reproduction
axeluhl Nov 26, 2025
a8e6fe3
issue-10181: fixed test case for recursive graph instantiability
axeluhl Nov 26, 2025
024b688
issue-10181: trying to replicate the type graph leading to a 20% erro…
axeluhl Nov 27, 2025
13923af
issue-10181: reproduced the problem by replacing UUID by String;
axeluhl Nov 27, 2025
48c7bc7
issue-10181: simplified type graph slightly
axeluhl Nov 27, 2025
e861951
issue-10181: successful test for serializability of recursive test graph
axeluhl Nov 28, 2025
4e2d092
issue-10181: added an unserializable subclass to the recursive graph
axeluhl Nov 29, 2025
452be57
issue-10181: reproducing multiple setInstantiable calls for same TIC
axeluhl Dec 1, 2025
bf1d9aa
issue-10181: stripped-down failing test case
axeluhl Dec 1, 2025
1d43061
issue-10181: streamlined test case
axeluhl Dec 1, 2025
90a639b
issue-10181: start type analysis from A; remove unused getters/setters
axeluhl Dec 2, 2025
67816ee
issue-10181: added simplified version of recursive type graph plus tests
axeluhl Dec 3, 2025
8ab92da
issue-10181: fixed import order again in SerializableTypeOracleBuilde…
axeluhl Dec 3, 2025
9f9ce55
Merge branch 'gwtproject:main' into issue-10181-clean
axeluhl Dec 4, 2025
a309d4d
issue-10181: revert .classpath changes to keep diff minimal
axeluhl Dec 4, 2025
fb9ced5
Merge commit 'd67edbb8cd22b4c9a7e57badce8ea9a2c61555a8' into issue-10…
axeluhl Dec 4, 2025
ad6dce0
issue-10181: added copyright headers to comply with checkstyles rules
axeluhl Dec 4, 2025
5bd0b3e
Merge remote-tracking branch 'githubsap/issue-10181-clean' into issue…
axeluhl Dec 4, 2025
5d73cb7
issue-10181: fixed checkstyle warnings
axeluhl Dec 4, 2025
a0ca1da
issue-10181: updated copyright header ("GWT project authors")
axeluhl Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,9 @@ TypeInfoComputed computeTypeInstantiability(TreeLogger logger, JType type, TypeP
Set<JClassType> instantiableTypes = new HashSet<JClassType>();
boolean anySubtypes =
checkSubtypes(localLogger, originalType, instantiableTypes, path, problems);
if (!tic.isDone()) {
if (tic.isPendingInstantiable()) {
tic.setInstantiableSubtypes(anySubtypes);
} else if (!tic.isDone()) {
Comment thread
axeluhl marked this conversation as resolved.
tic.setInstantiableSubtypes(anySubtypes);
tic.setInstantiable(false);
}
Expand Down Expand Up @@ -1147,9 +1149,14 @@ private boolean checkDeclaredFields(TreeLogger logger, TypeInfoComputed typeInfo
checkAllSubtypesOfObject(fieldLogger.branch(TreeLogger.WARN,
"Object was reached from a manually serializable type", null), path, problems);
} else {
allSucceeded &=
computeTypeInstantiability(fieldLogger, fieldType, path, problems)
.hasInstantiableSubtypes();
boolean hasInstantiableSubtypes = computeTypeInstantiability(fieldLogger, fieldType, path,
problems).hasInstantiableSubtypes();
allSucceeded &= hasInstantiableSubtypes;
if (!hasInstantiableSubtypes) {
fieldLogger.branch(TreeLogger.WARN, "Field type '"
+ fieldType.getParameterizedQualifiedSourceName()
+ "' has no instantiable subtypes");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import com.google.gwt.user.rebind.rpc.testcases.client.NotAllSubtypesAreSerializable;
import com.google.gwt.user.rebind.rpc.testcases.client.ParameterizedTypeInList;
import com.google.gwt.user.rebind.rpc.testcases.client.RawTypeInList;
import com.google.gwt.user.rebind.rpc.testcases.client.RecursiveTypeGraphInstantiability;
import com.google.gwt.user.rebind.rpc.testcases.client.SimplifiedRecursiveTypeGraphInstantiability;
import com.google.gwt.user.rebind.rpc.testcases.client.SubclassUsedInArray;

import junit.framework.TestCase;
Expand Down Expand Up @@ -1521,6 +1523,78 @@ public void testNotAllSubtypesAreSerializable() throws UnableToCompleteException
validateSTO(sto, expected);
}

public void testInstantiabilityDetectionOnRecursiveTypeGraphStartingAtA()
throws UnableToCompleteException, NotFoundException {
TreeLogger logger = createLogger();
TypeOracle typeOracle = getTestTypeOracle();
JClassType a = typeOracle.getType(RecursiveTypeGraphInstantiability.A.class.getCanonicalName());
SerializableTypeOracleBuilder stob = createSerializableTypeOracleBuilder(logger, typeOracle);
stob.addRootType(logger, a);
SerializableTypeOracle sto = stob.build(logger);
assertTrue("Expected type info for B to be present and marked instantiable but found " + Arrays
.asList(getActualTypeInfo(sto)) + ".", Arrays.asList(getActualTypeInfo(sto)).contains(
new TypeInfo(makeSourceName(RecursiveTypeGraphInstantiability.B.class.getName()),
true)));
TypeInfo[] expected = new TypeInfo[] {
new TypeInfo(makeSourceName(RecursiveTypeGraphInstantiability.B.class.getName()), true),
new TypeInfo(makeSourceName(RecursiveTypeGraphInstantiability.C.class.getName()), true)};
validateSTO(sto, expected);
}

public void testInstantiabilityDetectionOnRecursiveTypeGraphStartingAtB()
throws UnableToCompleteException, NotFoundException {
TreeLogger logger = createLogger();
TypeOracle typeOracle = getTestTypeOracle();
JClassType b = typeOracle.getType(RecursiveTypeGraphInstantiability.B.class.getCanonicalName());
Comment thread
axeluhl marked this conversation as resolved.
SerializableTypeOracleBuilder stob = createSerializableTypeOracleBuilder(logger, typeOracle);
stob.addRootType(logger, b);
SerializableTypeOracle sto = stob.build(logger);
assertTrue("Expected type info for B to be present and marked instantiable but found " + Arrays
.asList(getActualTypeInfo(sto)) + ".", Arrays.asList(getActualTypeInfo(sto)).contains(
new TypeInfo(makeSourceName(RecursiveTypeGraphInstantiability.B.class.getName()),
true)));
TypeInfo[] expected = new TypeInfo[] {
new TypeInfo(makeSourceName(RecursiveTypeGraphInstantiability.B.class.getName()), true),
new TypeInfo(makeSourceName(RecursiveTypeGraphInstantiability.C.class.getName()), true)};
validateSTO(sto, expected);
}

public void testInstantiabilityDetectionOnSimplifiedRecursiveTypeGraphStartingAtA()
throws UnableToCompleteException, NotFoundException {
TreeLogger logger = createLogger();
TypeOracle typeOracle = getTestTypeOracle();
JClassType a = typeOracle.getType(SimplifiedRecursiveTypeGraphInstantiability.A.class.getCanonicalName());
SerializableTypeOracleBuilder stob = createSerializableTypeOracleBuilder(logger, typeOracle);
stob.addRootType(logger, a);
SerializableTypeOracle sto = stob.build(logger);
assertTrue("Expected type info for B to be present and marked instantiable but found " + Arrays
.asList(getActualTypeInfo(sto)) + ".", Arrays.asList(getActualTypeInfo(sto)).contains(
new TypeInfo(makeSourceName(SimplifiedRecursiveTypeGraphInstantiability.B.class.getName()),
true)));
TypeInfo[] expected = new TypeInfo[] {
new TypeInfo(makeSourceName(SimplifiedRecursiveTypeGraphInstantiability.B.class.getName()), true),
new TypeInfo(makeSourceName(SimplifiedRecursiveTypeGraphInstantiability.C.class.getName()), true)};
validateSTO(sto, expected);
}

public void testInstantiabilityDetectionOnSimplifiedRecursiveTypeGraphStartingAtB()
throws UnableToCompleteException, NotFoundException {
TreeLogger logger = createLogger();
TypeOracle typeOracle = getTestTypeOracle();
JClassType b = typeOracle.getType(SimplifiedRecursiveTypeGraphInstantiability.B.class.getCanonicalName());
SerializableTypeOracleBuilder stob = createSerializableTypeOracleBuilder(logger, typeOracle);
stob.addRootType(logger, b);
SerializableTypeOracle sto = stob.build(logger);
assertTrue("Expected type info for B to be present and marked instantiable but found " + Arrays
.asList(getActualTypeInfo(sto)) + ".", Arrays.asList(getActualTypeInfo(sto)).contains(
new TypeInfo(makeSourceName(SimplifiedRecursiveTypeGraphInstantiability.B.class.getName()),
true)));
TypeInfo[] expected = new TypeInfo[] {
new TypeInfo(makeSourceName(SimplifiedRecursiveTypeGraphInstantiability.B.class.getName()), true),
new TypeInfo(makeSourceName(SimplifiedRecursiveTypeGraphInstantiability.C.class.getName()), true)};
validateSTO(sto, expected);
}

/**
* Tests that Object[] is not instantiable.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2025 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.user.rebind.rpc.testcases.client;

import com.google.gwt.user.client.rpc.IsSerializable;

public interface RecursiveTypeGraphInstantiability extends IsSerializable {
/**
* Not serializable; interface only.
*/
interface A extends IsSerializable {
}

/**
* Not serializable; interface only, the second interface implemented by {@link B}.
*/
interface D extends IsSerializable {
}

/**
* Default-serializable, but with back-reference to A for which the question of instantiable subtypes
* depends on the serializability of this class. The reference to {@link C} which
* has a back-reference to {@link B} and B being its only subtypes candidate
* helps reproduce issue 10181.
*/
class B implements A, D {
A a;
B b;
C c;
}

/**
* Default-serializable with back-reference to B through D, a different interface, triggering another
* descent through checkSubtypes, finding an already "done" TIC for {@link B} with
* {@code instantiable==false}. Being "done", it is used to decide instantiability of the only
* subclass candidate of {@link D}, which is {@link B}, resulting in {@code false} for
* the instantiability of {@link D}, and thus of {@link C}, and thus of {@link B}, causing
* the test case to fail prior to a fix for issue 10181.
*/
class C implements IsSerializable {
D d;
}

A getA();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2025 Google Inc.
Comment thread
axeluhl marked this conversation as resolved.
Outdated
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.user.rebind.rpc.testcases.client;

import com.google.gwt.user.client.rpc.IsSerializable;

public interface SimplifiedRecursiveTypeGraphInstantiability extends IsSerializable {
/**
* Not serializable; interface only.
*/
interface A extends IsSerializable {
}

/**
* Default serializable, but with back-reference to B for which the question of instantiable
* subtypes depends on the serializability of this class. The reference to {@link C} which has a
* back-reference to {@link A} and B being its only subtypes candidate helps reproduce issue
* 10181.
*/
class B implements A {
B b;
C c;
}
Comment thread
axeluhl marked this conversation as resolved.

class C implements IsSerializable {
A A;
}

A getA();
}