-
Notifications
You must be signed in to change notification settings - Fork 277
Java class literals: init using a library hook when possible #2237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
public @interface ExampleAnnotation { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
public enum ExampleEnum { | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
interface ExampleInterface { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
; Compile me with Jasmin 2.1+ (https://sourceforge.net/projects/jasmin/) | ||
|
||
.class public synthetic ExampleSynthetic | ||
.super java/lang/Object |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
public class Test { | ||
|
||
public static void main() { | ||
|
||
assert ExampleAnnotation.class.isAnnotation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly being dense but there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Er, yes. Will fix. |
||
assert ExampleInterface.class.isInterface(); | ||
assert ExampleEnum.class.isEnum(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing asserts for synethetic (which might be hard), local class and member class (which I suppose shouldn't be too hard to create?), this is obviously not important if these aren't supported, but for the avoidance of confusion, perhaps remove them from your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see only synthetic actually works - if possible please add an assert (perhaps using a hand created class file?) |
||
assert ExampleSynthetic.class.isSynthetic(); | ||
|
||
assert char[].class.isArray(); | ||
assert short[].class.isArray(); | ||
assert int[].class.isArray(); | ||
assert long[].class.isArray(); | ||
assert float[].class.isArray(); | ||
assert double[].class.isArray(); | ||
assert boolean[].class.isArray(); | ||
assert Object[].class.isArray(); | ||
assert Object[][].class.isArray(); | ||
|
||
// Note use of '==' not '.equals', as we expect the same exact literal, | ||
// which in jbmc always have the same address. | ||
// Note names of array classes are not tested yet, as arrays' types are | ||
// printed as their raw signature, to be addressed separately. | ||
// Note also primitive types (e.g. int.class) are not addresses here, as | ||
// they are created through box types' static initializers (e.g. Integer | ||
// has a static member TYPE that holds the Class for `int.class`) | ||
|
||
assert ExampleAnnotation.class.getName() == "ExampleAnnotation"; | ||
assert ExampleInterface.class.getName() == "ExampleInterface"; | ||
assert ExampleEnum.class.getName() == "ExampleEnum"; | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package java.lang; | ||
|
||
public class Class { | ||
|
||
private String name; | ||
|
||
private boolean isAnnotation; | ||
private boolean isArray; | ||
private boolean isInterface; | ||
private boolean isSynthetic; | ||
private boolean isLocalClass; | ||
private boolean isMemberClass; | ||
private boolean isEnum; | ||
|
||
public void cproverInitializeClassLiteral( | ||
String name, | ||
boolean isAnnotation, | ||
boolean isArray, | ||
boolean isInterface, | ||
boolean isSynthetic, | ||
boolean isLocalClass, | ||
boolean isMemberClass, | ||
boolean isEnum) { | ||
|
||
this.name = name; | ||
this.isAnnotation = isAnnotation; | ||
this.isArray = isArray; | ||
this.isInterface = isInterface; | ||
this.isSynthetic = isSynthetic; | ||
this.isLocalClass = isLocalClass; | ||
this.isMemberClass = isMemberClass; | ||
this.isEnum = isEnum; | ||
|
||
} | ||
|
||
public String getName() { return name; } | ||
|
||
public boolean isAnnotation() { return isAnnotation; } | ||
public boolean isArray() { return isArray; } | ||
public boolean isInterface() { return isInterface; } | ||
public boolean isSynthetic() { return isSynthetic; } | ||
public boolean isLocalClass() { return isLocalClass; } | ||
public boolean isMemberClass() { return isMemberClass; } | ||
public boolean isEnum() { return isEnum; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
Test.class | ||
|
||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--lazy-methods | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
lazy-methods is incompatible with symex-driven lazy loading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird empty lines (here and in other java files)