Skip to content

Commit 0cdb1bb

Browse files
Update to models-library@4d20c50
1 parent 5f2018b commit 0cdb1bb

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

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

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,58 @@
3939

4040
import org.cprover.CProver;
4141

42+
/**
43+
* Instances of the class {@code Class} represent classes and
44+
* interfaces in a running Java application. An enum is a kind of
45+
* class and an annotation is a kind of interface. Every array also
46+
* belongs to a class that is reflected as a {@code Class} object
47+
* that is shared by all arrays with the same element type and number
48+
* of dimensions. The primitive Java types ({@code boolean},
49+
* {@code byte}, {@code char}, {@code short},
50+
* {@code int}, {@code long}, {@code float}, and
51+
* {@code double}), and the keyword {@code void} are also
52+
* represented as {@code Class} objects.
53+
*
54+
* <p> {@code Class} has no public constructor. Instead {@code Class}
55+
* objects are constructed automatically by the Java Virtual Machine as classes
56+
* are loaded and by calls to the {@code defineClass} method in the class
57+
* loader.
58+
*
59+
* <p> The following example uses a {@code Class} object to print the
60+
* class name of an object:
61+
*
62+
* <blockquote><pre>
63+
* void printClassName(Object obj) {
64+
* System.out.println("The class of " + obj +
65+
* " is " + obj.getClass().getName());
66+
* }
67+
* </pre></blockquote>
68+
*
69+
* <p> It is also possible to get the {@code Class} object for a named
70+
* type (or for void) using a class literal. See Section 15.8.2 of
71+
* <cite>The Java&trade; Language Specification</cite>.
72+
* For example:
73+
*
74+
* <blockquote>
75+
* {@code System.out.println("The name of class Foo is: "+Foo.class.getName());}
76+
* </blockquote>
77+
*
78+
* @param <T> the type of the class modeled by this {@code Class}
79+
* object. For example, the type of {@code String.class} is {@code
80+
* Class<String>}. Use {@code Class<?>} if the class being modeled is
81+
* unknown.
82+
*
83+
* @author unascribed
84+
* @see java.lang.ClassLoader#defineClass(byte[], int, int)
85+
* @since JDK1.0
86+
*
87+
* @diffblue.limitedSupport
88+
* Generated tests that create an instance of Class will be incorrect:
89+
* <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>
92+
* </ul>
93+
*/
4294
public final class Class<T> {
4395

4496
private Class() {}
@@ -453,6 +505,7 @@ private static boolean desiredAssertionStatus0(Class<?> clazz) {
453505
protected void cproverNondetInitialize() {
454506
CProver.assume(name != null);
455507
CProver.assume(enumConstantDirectory == null);
508+
CProver.assume(classValueMap == null);
456509
}
457510

458511
// DIFFBLUE MODEL LIBRARY
@@ -607,6 +660,13 @@ public Method getMethod(String name, Class<?>... parameterTypes) throws NoSuchMe
607660
return new Method(this, name, parameterTypes);
608661
}
609662

663+
// DIFFBLUE MODEL LIBRARY
664+
// This field is never read in our model. We include them because ClassValue
665+
// (in the java library, not our models) references it, so it is needed to
666+
// make ClassValue compile.
667+
// transient ClassValue.ClassValueMap classValueMap;
668+
transient ClassValue.ClassValueMap classValueMap = null;
669+
610670
/**
611671
* Returns the {@code Class} representing the component type of an
612672
* array. If this class does not represent an array class this method
@@ -615,10 +675,12 @@ public Method getMethod(String name, Class<?>... parameterTypes) throws NoSuchMe
615675
* @return the {@code Class} representing the component type of this
616676
* class if this class is an array
617677
* @see java.lang.reflect.Array
618-
* @since 1.1
678+
* @since JDK1.1
679+
* @diffblue.noSupport
619680
*/
681+
// public native Class<?> getComponentType();
620682
public Class<?> getComponentType() {
621683
CProver.notModelled();
622-
return CProver.nondetWithoutNullForNotModelled();
684+
return CProver.nondetWithNullForNotModelled();
623685
}
624686
}

0 commit comments

Comments
 (0)