< prev index next >

test/hotspot/jtreg/runtime/valhalla/valuetypes/classfileparser/BadValueTypes.java

Print this page




  53         // Test that value type fields must be final.
  54         runTest("ValueFieldNotFinal", "Illegal field modifiers in class ValueFieldNotFinal");
  55 
  56         // Test that arrays cannot have ACC_FLATTENABLE set.
  57         runTest("ValueFlatArray", "ACC_FLATTENABLE cannot be specified for an array");
  58 
  59         // Test that a value type cannot have a method named init.
  60 /* TBD: uncomment when javac stops generating <init>() methods for value types.
  61         runTest("ValueInitMethod", "Value Type cannot have a method named <init>");
  62 */
  63 
  64         // Test that ACC_VALUE with ACC_INTERFACE is illegal.
  65         runTest("ValueInterface", "Illegal class modifiers in class ValueInterface");
  66 
  67         // Test that value type instance methods cannot be synchronized.
  68         runTest("ValueMethodSynch", "Method instanceMethod in class ValueMethodSynch has illegal modifiers");
  69 
  70         runTest("ValueSuperClass", "Value type must have java.lang.Object as superclass");
  71 
  72         // Test that ClassCircularityError gets detected for instance fields.

  73         try {
  74             Class newClass = Class.forName("Circ");
  75             throw new RuntimeException( "java.lang.ClassCircularityError exception not thrown!");
  76         } catch (java.lang.ClassCircularityError e) {
  77              if (!e.getMessage().contains("Circ2")) {
  78                  throw new RuntimeException( "Wrong ClassCircularityError: " + e.getMessage());
  79              }
  80          }
  81 
  82         // Test that ClassCircularityError gets detected for static fields.

  83         try {
  84             Class newClass = Class.forName("CircStaticB");
  85             throw new RuntimeException( "java.lang.ClassCircularityError exception not thrown!");
  86         } catch (java.lang.ClassCircularityError e) {
  87              if (!e.getMessage().contains("CircStaticA")) {
  88                  throw new RuntimeException( "Wrong ClassCircularityError: " + e.getMessage());
  89              }
  90          }
  91 
  92         runTest("ValueCloneable", "Value Types do not support Cloneable");
  93     }
  94 }


  53         // Test that value type fields must be final.
  54         runTest("ValueFieldNotFinal", "Illegal field modifiers in class ValueFieldNotFinal");
  55 
  56         // Test that arrays cannot have ACC_FLATTENABLE set.
  57         runTest("ValueFlatArray", "ACC_FLATTENABLE cannot be specified for an array");
  58 
  59         // Test that a value type cannot have a method named init.
  60 /* TBD: uncomment when javac stops generating <init>() methods for value types.
  61         runTest("ValueInitMethod", "Value Type cannot have a method named <init>");
  62 */
  63 
  64         // Test that ACC_VALUE with ACC_INTERFACE is illegal.
  65         runTest("ValueInterface", "Illegal class modifiers in class ValueInterface");
  66 
  67         // Test that value type instance methods cannot be synchronized.
  68         runTest("ValueMethodSynch", "Method instanceMethod in class ValueMethodSynch has illegal modifiers");
  69 
  70         runTest("ValueSuperClass", "Value type must have java.lang.Object as superclass");
  71 
  72         // Test that ClassCircularityError gets detected for instance fields.
  73         System.out.println("Testing ClassCircularityError for instance fields");
  74         try {
  75             Class newClass = Class.forName("Circ");
  76             throw new RuntimeException( "java.lang.ClassCircularityError exception not thrown!");
  77         } catch (java.lang.ClassCircularityError e) {
  78              if (!e.getMessage().contains("Circ")) {
  79                  throw new RuntimeException( "Wrong ClassCircularityError: " + e.getMessage());
  80              }
  81          }
  82 
  83         // Test that ClassCircularityError gets detected for static fields.
  84         System.out.println("Testing ClassCircularityError for static fields");
  85         try {
  86             Class newClass = Class.forName("CircStaticB");
  87             throw new RuntimeException( "java.lang.ClassCircularityError exception not thrown!");
  88         } catch (java.lang.ClassCircularityError e) {
  89              if (!e.getMessage().contains("CircStatic")) {
  90                  throw new RuntimeException( "Wrong ClassCircularityError: " + e.getMessage());
  91              }
  92          }
  93 
  94         runTest("ValueCloneable", "Value Types do not support Cloneable");
  95     }
  96 }
< prev index next >