Skip to content

Commit

Permalink
Add field tests for abstract value classes
Browse files Browse the repository at this point in the history
  • Loading branch information
fparain committed Jun 5, 2024
1 parent 05a43aa commit 0621ff0
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ public static void main(String[] args) throws Exception {
// Test that ACC_STRICT without ACC_FINAL is illegal.
runTest("StrictNotFinal", "Illegal field modifiers (strict field must be final) in class StrictNotFinal: 0x800");

// Test that a value class cannot have field without ACC_STATIC or ACC_STRICT
// Test that a concrete value class cannot have field without ACC_STATIC or ACC_STRICT
runTest("NotStaticNotStrict", "Illegal field modifiers (value class fields must be either strict or static) in class NotStaticNotStrict: 0x10");

// Test that an abstract value class cannot have field without ACC_STATIC or ACC_STRICT
runTest("NotStaticNotStrictInAbstract", "Illegal field modifiers (value class fields must be either strict or static) in class NotStaticNotStrictInAbstract: 0x10");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class StrictNotFinal {
} // Attributes
} // end class StrictNotFinal

// A value class declaring a field without ACC_STATIC nor ACC_STRICT
// A concrete value class declaring a field without ACC_STATIC nor ACC_STRICT
//
class NotStaticNotStrict {
0xCAFEBABE;
Expand Down Expand Up @@ -514,4 +514,124 @@ class NotStaticNotStrict {
#22;
} // end SourceFile
} // Attributes
} // end class NotStaticNotStrict
} // end class NotStaticNotStrict

// An abstract value class declaring a field without ACC_STATIC nor ACC_STRICT
//
class NotStaticNotStrictInAbstract {
0xCAFEBABE;
65535; // minor version
67; // version
[] { // Constant Pool
; // first element is empty
Field #2 #3; // #1
class #4; // #2
NameAndType #5 #6; // #3
Utf8 "NotStaticNotStrictInAbstract"; // #4
Utf8 "i"; // #5
Utf8 "I"; // #6
Method #8 #9; // #7
class #10; // #8
NameAndType #11 #12; // #9
Utf8 "java/lang/Object"; // #10
Utf8 "<init>"; // #11
Utf8 "()V"; // #12
Field #2 #14; // #13
NameAndType #15 #6; // #14
Utf8 "si"; // #15
Utf8 "ConstantValue"; // #16
int 0x00000000; // #17
Utf8 "Code"; // #18
Utf8 "LineNumberTable"; // #19
Utf8 "<clinit>"; // #20
Utf8 "SourceFile"; // #21
Utf8 "NotStaticNotStrictInAbstract.java"; // #22
} // Constant Pool

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

[] { // Interfaces
} // Interfaces

[] { // Fields
{ // field
0x0008; // access
#15; // name_index
#6; // descriptor_index
[] { // Attributes
} // Attributes
}
;
{ // field
0x0010; // access
#5; // name_index
#6; // descriptor_index
[] { // Attributes
Attr(#16) { // ConstantValue
#17;
} // end ConstantValue
} // Attributes
}
} // Fields

[] { // Methods
{ // method
0x0001; // access
#11; // name_index
#12; // descriptor_index
[] { // Attributes
Attr(#18) { // Code
2; // max_stack
1; // max_locals
Bytes[]{
0x2A03B500012AB700;
0x07B1;
}
[] { // Traps
} // end Traps
[] { // Attributes
Attr(#19) { // LineNumberTable
[] { // line_number_table
0 3;
5 1;
9 3;
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
;
{ // method
0x0008; // access
#20; // name_index
#12; // descriptor_index
[] { // Attributes
Attr(#18) { // Code
1; // max_stack
0; // max_locals
Bytes[]{
0x03B3000DB1;
}
[] { // Traps
} // end Traps
[] { // Attributes
Attr(#19) { // LineNumberTable
[] { // line_number_table
0 2;
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
}
} // Methods

[] { // Attributes
Attr(#21) { // SourceFile
#22;
} // end SourceFile
} // Attributes
} // end class NotStaticNotStrictInAbstract

0 comments on commit 0621ff0

Please sign in to comment.