Skip to content

Commit 75beb6b

Browse files
Class.forName is not sufficiently modelled
We do not trigger static initializer execution atm.
1 parent a166069 commit 75beb6b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/java/lang/Class.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
* @diffblue.limitedSupport
8888
* Generated tests that create an instance of Class will be incorrect:
8989
* <ul>
90-
* <li>TG-7636: IllegalAccessError error when attempting to set the java.lang.class via reflection</li>
91-
* <li>TG-4727: When test-gen mocks java.lang.Class, it causes IllegalAccessError</li>
90+
* <li>IllegalAccessError error when attempting to set the java.lang.class via reflection</li>
91+
* <li>When JBMC mocks java.lang.Class, it causes IllegalAccessError</li>
9292
* </ul>
9393
*/
9494
public final class Class<T> {
@@ -170,6 +170,9 @@ public String toGenericString() {
170170
// forName method. The goal is to correctly model combinations of forName
171171
// and getName, but precisely following the JDK behaviour is more involved.
172172
public static Class<?> forName(String className) {
173+
CProver.notModelled();
174+
throw new AssertionError();
175+
/*
173176
String foundName = null;
174177
for (int i = 0; i < cproverClassNames.length; ++i) {
175178
String currentName = cproverClassNames[i];
@@ -185,6 +188,7 @@ public static Class<?> forName(String className) {
185188
}
186189
}
187190
return CProver.nondetWithoutNullForNotModelled();
191+
*/
188192
}
189193

190194
public static Class<?> forName(String name, boolean initialize,
@@ -276,7 +280,7 @@ ClassLoader getClassLoader0() {
276280
// DIFFBLUE MODEL LIBRARY The real java.lang.Class stores a
277281
// `private final ClassLoader classLoader` which is initialised by the
278282
// jvm rather than by the constructor of this object.
279-
// TODO test-gen should understand this method natively.
283+
// TODO JBMC should understand this method natively.
280284
return null;
281285
}
282286

0 commit comments

Comments
 (0)