Skip to content

Commit

Permalink
More tests of VM fixing missing ACC_IDENTITY
Browse files Browse the repository at this point in the history
  • Loading branch information
fparain committed Jun 6, 2024
1 parent 71ce77b commit 959a817
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ public static void main(String[] args) throws Exception {
// Test a concrete value class extending an abstract identity class
runTest("ValueClass", null, "Value type ValueClass has an identity type as supertype");

// Test a concrete identity class without ACC_IDENTITY but with an older class file version, extending an abstract identity class
// (Test that the VM fixes missing ACC_IDENTITY in old class files)
runTest("IdentityClass", null, null);

// Test a concrete value class extending a concrete (i.e. final) value class
runTest("ValueClass2", null, "class ValueClass2 cannot inherit from final class FinalValue");

// Test an abstract value class extending an abstract identity class
runTest("AbstractValueClass2", null, "Value type AbstractValueClass2 has an identity type as supertype");

// Test an abstract identity class without ACC_IDENTITY but with an older class file version, extending an abstract identity class
// (Test that the VM fixes missing ACC_IDENTITY in old class files)
runTest("AbstractIdentityClass2", null, null);

// Test an abstract value class extending a concrete (i.e. final) value class
runTest("AbstractValueClass3", null, "class AbstractValueClass3 cannot inherit from final class FinalValue");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,70 @@ class ValueClass {
} // Attributes
} // end class ValueClass

// Concrete identity class from old class file without ACC_IDENTITY extending the abstract (with identity) class define above
class IdentityClass {
0xCAFEBABE;
0; // minor version
67; // version
[] { // Constant Pool
; // first element is empty
Method #2 #3; // #1
class #4; // #2
NameAndType #5 #6; // #3
Utf8 "AbstractClass"; // #4
Utf8 "<init>"; // #5
Utf8 "()V"; // #6
class #8; // #7
Utf8 "IdentityClass"; // #8
Utf8 "Code"; // #9
Utf8 "LineNumberTable"; // #10
Utf8 "SourceFile"; // #11
Utf8 "IdentityClass.java"; // #12
} // Constant Pool

0x0011; // access
#7;// this_cpx
#2;// super_cpx

[] { // Interfaces
} // Interfaces

[] { // Fields
} // Fields

[] { // Methods
{ // method
0x0001; // access
#5; // name_index
#6; // descriptor_index
[] { // Attributes
Attr(#9) { // Code
1; // max_stack
1; // max_locals
Bytes[]{
0x2AB70001B1;
}
[] { // Traps
} // end Traps
[] { // Attributes
Attr(#10) { // LineNumberTable
[] { // line_number_table
0 1;
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
} // Methods

[] { // Attributes
Attr(#11) { // SourceFile
#12;
} // end SourceFile
} // Attributes
} // end class ValueClass

// Concrete value class extending a final value class
class ValueClass2 {
0xCAFEBABE;
Expand Down Expand Up @@ -474,6 +538,70 @@ class AbstractValueClass2 {
} // Attributes
} // end class AbstractValueClass2

// Abstract identity class from older class file without ACC_IDENTITY, extending an abstract (with identity) class
class AbstractIdentityClass2 {
0xCAFEBABE;
0; // minor version
67; // version
[] { // Constant Pool
; // first element is empty
Method #2 #3; // #1
class #4; // #2
NameAndType #5 #6; // #3
Utf8 "AbstractClass"; // #4
Utf8 "<init>"; // #5
Utf8 "()V"; // #6
class #8; // #7
Utf8 "AbstractIdentityClass2"; // #8
Utf8 "Code"; // #9
Utf8 "LineNumberTable"; // #10
Utf8 "SourceFile"; // #11
Utf8 "AbstractIdentityClass2.java"; // #12
} // Constant Pool

0x0401; // access
#7;// this_cpx
#2;// super_cpx

[] { // Interfaces
} // Interfaces

[] { // Fields
} // Fields

[] { // Methods
{ // method
0x0001; // access
#5; // name_index
#6; // descriptor_index
[] { // Attributes
Attr(#9) { // Code
1; // max_stack
1; // max_locals
Bytes[]{
0x2AB70001B1;
}
[] { // Traps
} // end Traps
[] { // Attributes
Attr(#10) { // LineNumberTable
[] { // line_number_table
0 1;
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
} // Methods

[] { // Attributes
Attr(#11) { // SourceFile
#12;
} // end SourceFile
} // Attributes
} // end class AbstractValueClass2

// Abstract value class extending a final value class
class AbstractValueClass3 {
0xCAFEBABE;
Expand Down

0 comments on commit 959a817

Please sign in to comment.