]> source.dussan.org Git - aspectj.git/commitdiff
Remove most MINOR_*, MINOR_* BCEL class file versions
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 19 Feb 2024 06:19:49 +0000 (13:19 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 19 Feb 2024 06:19:49 +0000 (13:19 +0700)
in favour of Constants.ClassFileVersion.of(int, int). The few ones
retained are used from production code, the vast majority of removed
ones only from test code.

This gets rid of yet another 'AspectJ_JDK_Update' tag. One less place to
check and update with each newly supported Java version. :-)

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
26 files changed:
bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java
bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/ModuleTest.java
tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java
tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java
tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java
tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java
tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java
tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java
tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java
tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java
tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java
tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java
tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java
tests/src/test/java/org/aspectj/systemtest/ajc196/Java14PreviewFeaturesTests.java
tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java
tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java
tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java
tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java
tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java
tests/src/test/java/org/aspectj/systemtest/ajc198/CompileWithReleaseTests.java
tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java
tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java
tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java
tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java

index 5b96bb6d121e98b94fdd32ab17222c74463d96c4..566133f173a746aea8609e68833428e03b7ff039 100644 (file)
@@ -2,6 +2,10 @@ package org.aspectj.apache.bcel;
 
 import org.aspectj.apache.bcel.generic.Type;
 
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+
 /* ====================================================================
  * The Apache Software License, Version 1.1
  *
@@ -63,58 +67,83 @@ import org.aspectj.apache.bcel.generic.Type;
  * @author Andy Clement
  */
 public interface Constants {
-       // Major and minor version of the code
-       short MAJOR_1_1 = 45;
-       short MINOR_1_1 = 3;
-       short MAJOR_1_2 = 46;
-       short MINOR_1_2 = 0;
-       short MAJOR_1_3 = 47;
-       short MINOR_1_3 = 0;
-       short MAJOR_1_4 = 48;
-       short MINOR_1_4 = 0;
-       short MAJOR_1_5 = 49;
-       short MINOR_1_5 = 0;
-       short MAJOR_1_6 = 50;
-       short MINOR_1_6 = 0;
-       short MAJOR_1_7 = 51;
-       short MINOR_1_7 = 0;
-       short MAJOR_1_8 = 52;
-       short MINOR_1_8 = 0;
-       short MAJOR_1_9 = 53;
-       short MINOR_1_9 = 0;
-       short MAJOR_10 = 54;
-       short MINOR_10 = 0;
-       short MAJOR_11 = 55;
-       short MINOR_11 = 0;
-       short MAJOR_12 = 56;
-       short MINOR_12 = 0;
-       short MAJOR_13 = 57;
-       short MINOR_13 = 0;
-       short MAJOR_14 = 58;
-       short MINOR_14 = 0;
-       short MAJOR_15 = 59;
-       short MINOR_15 = 0;
-       short MAJOR_16 = 60;
-       short MINOR_16 = 0;
-       short MAJOR_17 = 61;
-       short MINOR_17 = 0;
-       short MAJOR_18 = 62;
-       short MINOR_18 = 0;
-       short MAJOR_19 = 63;
-       short MINOR_19 = 0;
-       short MAJOR_20 = 64;
-       short MINOR_20 = 0;
-       short MAJOR_21 = 65;
-       short MINOR_21 = 0;
-       // AspectJ_JDK_Update
-//     short MAJOR_22 = 66;
-//     short MINOR_22 = 0;
-
-       int PREVIEW_MINOR_VERSION = 65535;
-
-       // Defaults
-       short MAJOR = MAJOR_1_1;
-       short MINOR = MINOR_1_1;
+       // Selected major/minor class file versions, defined as constants because they are used in production code. Maybe,
+       // there is a slight performance advantage, therefore retain them. When tests need class file version infos, they
+       // should use ClassFileVersion.of(javaMajor) instead, avoiding new constants for every major Java release. In the
+       // past, we had too many of them.
+       int MAJOR_1_1 = 45;
+       int MINOR_1_1 = 3;
+       int MAJOR_1_5 = 49;
+       int MAJOR_1_6 = 50;
+       int MAJOR_1_8 = 52;
+
+       /**
+        * Carries information about major, minor and preview-minor version byte values found in Java class files for a
+        * specific Java version. You can obtain instances via {@link #of(int)} and {@link #of(int, int)}, respectively.
+        */
+       class ClassFileVersion {
+               private static final Map<Integer, ClassFileVersion> cache = new ConcurrentHashMap<>();
+
+               public final int MAJOR;
+               public final int MINOR;
+               public final int PREVIEW_MINOR = 65535;
+
+               private ClassFileVersion(int major, int minor) {
+                       MAJOR = major;
+                       MINOR = minor;
+               }
+
+               /**
+                * Obtain a class file version info instance for a specific Java version
+                *
+                * @param javaMajor Java major version; must be >= 2; values 2 to 9 are interpreted as Java versions 1.2 to 1.9
+                *
+                * @return either a cached or a new instance; result is identical to calling {@code of(javaMajor, 0)}
+                */
+               public static ClassFileVersion of(int javaMajor) {
+                       return of(javaMajor, 0);
+               }
+
+               /**
+                * Obtain a class file version info instance for a specific Java version
+                *
+                * @param javaMajor Java major version; must be >= 1; values 2 to 9 are interpreted as Java versions 1.2 to 1.9
+                * @param javaMinor Java minor version; is only relevant for Java major 1 and must be in range [1..9]
+                *
+                * @return either a cached or a new instance
+                */
+               public static ClassFileVersion of(int javaMajor, int javaMinor) {
+                       if (javaMajor < 1)
+                               throw new IllegalArgumentException("Java major version must be >= 1");
+                       if (javaMajor == 1) {
+                               if (javaMinor < 1 || javaMinor > 9)
+                                       throw new IllegalArgumentException("Java 1.x versions must be 1.1 to 1.9");
+                               // 1.1 -> 1, ..., 1.5 -> 5, ..., 1.9 -> 9
+                               javaMajor = javaMinor;
+                       }
+                       ClassFileVersion classFileVersion = cache.get(javaMajor);
+                       if (classFileVersion == null) {
+                               classFileVersion = new ClassFileVersion(javaMajor + 44, javaMajor == 1 ? 3 : 0);
+                               cache.put(javaMajor, classFileVersion);
+                       }
+                       return classFileVersion;
+               }
+
+               @Override
+               public boolean equals(Object o) {
+                       if (this == o) return true;
+                       if (!(o instanceof ClassFileVersion)) return false;
+                       ClassFileVersion that = (ClassFileVersion) o;
+                       // Include PREVIEW_MINOR, if it ever changes to be non-constant
+                       return MAJOR == that.MAJOR && MINOR == that.MINOR /*&& PREVIEW_MINOR == that.PREVIEW_MINOR*/;
+               }
+
+               @Override
+               public int hashCode() {
+                       // Include PREVIEW_MINOR, if it ever changes to be non-constant
+                       return Objects.hash(MAJOR, MINOR/*, PREVIEW_MINOR*/);
+               }
+       }
 
        /** Maximum value for an unsigned short */
        int MAX_SHORT = 65535; // 2^16 - 1
index f8012a983bc4d17a7d82416fad812ad2087e3bf9..b52c89e4fea81cf44e8aa0e0dc253fd610643104 100644 (file)
@@ -36,8 +36,8 @@ public class ModuleTest extends BcelTestCase {
                ClassParser classParser = new ClassParser(moduleFilename);
                JavaClass javaClass = classParser.parse();
                assertNotNull(javaClass);
-               assertEquals(Constants.MAJOR_1_9,javaClass.getMajor());
-               assertEquals(Constants.MINOR_1_9,javaClass.getMinor());
+               assertEquals(Constants.ClassFileVersion.of(9).MAJOR, javaClass.getMajor());
+               assertEquals(Constants.ClassFileVersion.of(9).MINOR, javaClass.getMinor());
                assertEquals(Constants.ACC_MODULE,javaClass.getModifiers());
                assertEquals(0,javaClass.getSuperclassNameIndex());
                assertEquals(0,javaClass.getInterfaceIndices().length);
index 4a7c39a0127ba72c7a0e3c43d7ae3f51e8b981ba..619114dfa2bb0fe4dc892cd6a1abe1fd30578ca0 100644 (file)
@@ -26,7 +26,7 @@ import junit.framework.Test;
  * rather than executing them.
  */
 public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase {
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_1_6;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(6).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -83,7 +83,7 @@ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
        public void testVersionCorrect4() throws ClassNotFoundException {// check it is 49.0 when -1.5 is specified
                runTest("simple - m");
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        // Check the stackmap stuff appears for methods in a Java6 file
index ac5b109e66f20cfd19cc2d708d98e342e6544e01..38678b7508c7a4360acab54310350e5dbf34ab69 100644 (file)
@@ -21,7 +21,7 @@ import junit.framework.Test;
  * to check code generation and modification with that version specified.
  */
 public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_1_9;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(9).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
 
        public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
                runTest("simple - m");
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        // Check the stackmap stuff appears for methods in a Java6 file
index 5d5a0456410a84f96237b832daf5103d2605db0c..79c6ba1ae23be56f91e17c29c1470d820bd76fb3 100644 (file)
@@ -20,7 +20,7 @@ import junit.framework.Test;
  * @author Andy Clement
  */
 public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase {
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_10;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(10).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -71,7 +71,7 @@ public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase {
 
        public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
                runTest("simple - m");
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        // ///////////////////////////////////////
index b4dc12f39f2519a07585a059f13c8218c1ba2b74..1207f5cc6a5148726b73f104ec8e49c9df556e26 100644 (file)
@@ -16,18 +16,19 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava19Only;
  * @author Alexander Kriegisch
  */
 public class Java19PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava19Only {
+  private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(19);
 
   public void testSwitchPatternMatchingPreview3Java() {
     runTest("switch pattern matching preview 3 java");
-    checkVersion("SwitchPatternPreview3OK", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternPreview3OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingPreview3Aspect() {
     runTest("switch pattern matching preview 3 aspect");
-    checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Application", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Shape", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("S", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternPreview3Aspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("S", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
index a8a3826ea89a02bb7a6471dd94c29535a024f107..9f70c3ff291cc105271db5c9ab71f6de58a73067 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater;
  */
 public class SanityTestsJava19 extends XMLBasedAjcTestCaseForJava19OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_19;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(19).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava19 extends XMLBasedAjcTestCaseForJava19OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index b0f2cdb672fe5e8809d666b218f712851a21be98..e0b9034f86e1eed33479c1c91d1a0da45e9ea670 100644 (file)
@@ -21,7 +21,7 @@ import junit.framework.Test;
  * @author Andy Clement
  */
 public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_11;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(11).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -72,7 +72,7 @@ public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
 
        public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
                runTest("simple - m");
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
 
index 89a0a61c69eca25782adc4b113c7c51f890102ba..1a305bce1631b3dfbe2f8a1e5c52ac9cd9fa8d01 100644 (file)
@@ -16,10 +16,11 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava20Only;
  * @author Alexander Kriegisch
  */
 public class Java20PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava20Only {
+  private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(20);
 
   public void testSwitchPatternMatchingPreview4Java() {
     runTest("switch pattern matching preview 4 java");
-    checkVersion("SwitchPatternPreview4OK", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternPreview4OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingPreview4Error() {
@@ -28,10 +29,10 @@ public class Java20PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava20Only
 
   public void testSwitchPatternMatchingPreview3Aspect() {
     runTest("switch pattern matching preview 3 aspect");
-    checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Application", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Shape", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("S", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternPreview3Aspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("S", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
@@ -54,8 +55,8 @@ public class Java20PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava20Only
   public void testRecordPatternsPreview1Error() {
     // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27)
     runTest("record patterns error");
-    checkVersion("RecordPatternsPreview1Error", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Box", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("RecordPatternsPreview1Error", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Box", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testRecordPatternsPreview1ExhaustivenessOK1() {
index 88b9670e95ac9b8e1787b3eeb5c8f4d90f117d39..6cd0fd6b7bdcb77fccda1774ac2a5f2492826d02 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava20OrLater;
  */
 public class SanityTestsJava20 extends XMLBasedAjcTestCaseForJava20OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_20;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(20).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava20 extends XMLBasedAjcTestCaseForJava20OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index b0eaf3939d548bdaa7ded1600bec8d394fc90b6d..466135dc258720b1a615e2cb0291329bc6e729fb 100644 (file)
@@ -19,7 +19,7 @@ public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {
 
   public void testSwitchPatternMatchingPreview4Java() {
     runTest("switch pattern matching preview 4 java");
-    checkVersion("SwitchPatternPreview4OK", Constants.MAJOR_21, Constants.MINOR_21);
+    checkVersion("SwitchPatternPreview4OK", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
   }
 
   public void testSwitchPatternMatchingPreview4Error() {
@@ -28,10 +28,10 @@ public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {
 
   public void testSwitchPatternMatchingPreview3Aspect() {
     runTest("switch pattern matching preview 3 aspect");
-    checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_21, Constants.MINOR_21);
-    checkVersion("Application", Constants.MAJOR_21, Constants.MINOR_21);
-    checkVersion("Shape", Constants.MAJOR_21, Constants.MINOR_21);
-    checkVersion("S", Constants.MAJOR_21, Constants.MINOR_21);
+    checkVersion("SwitchPatternPreview3Aspect", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
+    checkVersion("Application", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
+    checkVersion("Shape", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
+    checkVersion("S", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
   }
 
   public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
@@ -54,8 +54,8 @@ public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {
   public void testRecordPatternsPreview1Error() {
     // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27)
     runTest("record patterns error");
-    checkVersion("RecordPatternsPreview1Error", Constants.MAJOR_21, Constants.MINOR_21);
-    checkVersion("Box", Constants.MAJOR_21, Constants.MINOR_21);
+    checkVersion("RecordPatternsPreview1Error", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
+    checkVersion("Box", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
   }
 
   public void testRecordPatternsPreview1ExhaustivenessOK1() {
index ed2216fdb9c8bb4e6f1ed045ba6922ec0489ff9b..2f4810e4e0731e4e100a10899acde08db74c0aef 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater;
  */
 public class SanityTestsJava21 extends XMLBasedAjcTestCaseForJava21OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_21;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(21).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava21 extends XMLBasedAjcTestCaseForJava21OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index 54397cf2f2e1d8db1ad4028aba26bb565fcfafaf..34901eb0086a16accc6388e5695f59e473a2c3ea 100644 (file)
@@ -22,7 +22,7 @@ import junit.framework.Test;
  */
 public class SanityTestsJava13 extends XMLBasedAjcTestCaseForJava13OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_13;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(13).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava13 extends XMLBasedAjcTestCaseForJava13OrLater {
 
        public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
                runTest("simple - m");
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
 
index 1669f7956a6219c7584e533ade8f1546d855cfa5..5659b293161a721d7427eb21b4e822bb628a37b3 100644 (file)
@@ -24,17 +24,17 @@ public class Ajc196Tests extends XMLBasedAjcTestCaseForJava14OrLater {
 
   public void testSwitch1() {
     runTest("switch 1");
-    checkVersion("Switch1", Constants.MAJOR_14, 0);
+    checkVersion("Switch1", Constants.ClassFileVersion.of(14).MAJOR, 0);
   }
 
   public void testSwitch2() {
     runTest("switch 2");
-    checkVersion("Switch2", Constants.MAJOR_14, 0);
+    checkVersion("Switch2", Constants.ClassFileVersion.of(14).MAJOR, 0);
   }
 
   public void testSwitch3() {
     runTest("switch 3");
-    checkVersion("Switch3", Constants.MAJOR_14, 0);
+    checkVersion("Switch3", Constants.ClassFileVersion.of(14).MAJOR, 0);
   }
 
   public static Test suite() {
index 6c31f0af2fda063e8fb16423416d613a91dcd81a..24b02101e88d65ec5e6e39aaeecb476583d0a54e 100644 (file)
@@ -17,10 +17,11 @@ import junit.framework.Test;
  * @author Alexander Kriegisch
  */
 public class Java14PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava14Only {
+  private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(14);
 
   public void testRecords() {
     runTest("simple record");
-    checkVersion("Person", Constants.MAJOR_14, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("Person", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testRecords2() {
index 960ba44205f7656881c167aff5695887fdb92567..13094e0484d96b4f5577a7fb60efc33249840cf8 100644 (file)
@@ -22,7 +22,7 @@ import junit.framework.Test;
  */
 public class SanityTestsJava14 extends XMLBasedAjcTestCaseForJava14OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_14;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(14).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -74,7 +74,7 @@ public class SanityTestsJava14 extends XMLBasedAjcTestCaseForJava14OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index 5e18926fc82c845f6588fd81e5079ac57762862e..8a1f794f4151466661f80074acca249af6343ade 100644 (file)
@@ -19,37 +19,37 @@ public class Ajc197TestsJava extends XMLBasedAjcTestCaseForJava16OrLater {
 
   public void testHiddenClass() {
     runTest("hidden class");
-    checkVersion("HiddenClassDemo", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("HiddenClassDemo", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public void testTextBlock1() {
     runTest("textblock 1");
-    checkVersion("Code", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("Code", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public void testTextBlock2() {
     runTest("textblock 2");
-    checkVersion("Code2", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("Code2", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public void testRecords() {
     runTest("simple record");
-    checkVersion("Person", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("Person", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public void testRecords2() {
     runTest("using a record");
-    checkVersion("UsingPersonRecord", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("UsingPersonRecord", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public void testAdvisingRecords() {
     runTest("advising records");
-    checkVersion("TraceRecordComponents", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("TraceRecordComponents", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public void testInstanceofPatterns() {
     runTest("instanceof patterns");
-    checkVersion("Jep305", Constants.MAJOR_16, Constants.MINOR_16);
+    checkVersion("Jep305", Constants.ClassFileVersion.of(16).MAJOR, Constants.ClassFileVersion.of(16).MINOR);
   }
 
   public static Test suite() {
index dbcbcf06ab8b1ae140f7e005bbe91905ab64fc97..f2c04e08cfcd6686bccca445cd931fec267dc1e9 100644 (file)
@@ -16,21 +16,22 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava16Only;
  * @author Alexander Kriegisch
  */
 public class Java16PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava16Only {
+  private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(16);
 
   public void testSealedClassWithLegalSubclasses() {
     runTest("sealed class with legal subclasses");
-    checkVersion("Employee", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Manager", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("Employee", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Manager", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSealedClassWithIllegalSubclass() {
     runTest("sealed class with illegal subclass");
-    checkVersion("Person", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("Person", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testWeaveSealedClass() {
     runTest("weave sealed class");
-    checkVersion("PersonAspect", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("PersonAspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public static Test suite() {
index a7ee41d5fdbefab1098c2939e0c632c1c277d188..d244ebea76218351fdcbbffa76a7ca71cebe2e59 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater;
  */
 public class SanityTestsJava15 extends XMLBasedAjcTestCaseForJava15OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_15;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(15).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava15 extends XMLBasedAjcTestCaseForJava15OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index 185660b152fe0a42a02315467600497a8e39c769..1e42ce6d71e4956533678972dba7367440112759 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
  */
 public class SanityTestsJava16 extends XMLBasedAjcTestCaseForJava16OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_16;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(16).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava16 extends XMLBasedAjcTestCaseForJava16OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index 3e6ead46744ccc02f995ad6982e17eb0429b685b..4df00392155358e01c58e26b17cdbcde9c33137d 100644 (file)
@@ -19,18 +19,18 @@ public class Ajc198TestsJava extends XMLBasedAjcTestCaseForJava17OrLater {
 
   public void testSealedClassWithLegalSubclasses() {
     runTest("sealed class with legal subclasses");
-    checkVersion("Employee", Constants.MAJOR_17, Constants.MINOR_17);
-    checkVersion("Manager", Constants.MAJOR_17, Constants.MINOR_17);
+    checkVersion("Employee", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
+    checkVersion("Manager", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
   }
 
   public void testSealedClassWithIllegalSubclass() {
     runTest("sealed class with illegal subclass");
-    checkVersion("Person", Constants.MAJOR_17, Constants.MINOR_17);
+    checkVersion("Person", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
   }
 
   public void testWeaveSealedClass() {
     runTest("weave sealed class");
-    checkVersion("PersonAspect", Constants.MAJOR_17, Constants.MINOR_17);
+    checkVersion("PersonAspect", Constants.ClassFileVersion.of(17).MAJOR, Constants.ClassFileVersion.of(17).MINOR);
   }
 
   public static Test suite() {
index c24c7e58e08e24b29fd98692e203c7ca0a6ad702..b0fb2745ba18eae82d4e0ec2b012d0e6099eec5f 100644 (file)
@@ -32,7 +32,7 @@ public class CompileWithReleaseTests extends XMLBasedAjcTestCaseForJava9OrLater
 
     // Check compiled byte code version
     String className = "Buffers";
-    checkVersion(className, Constants.MAJOR_1_8, Constants.MINOR_1_8);
+    checkVersion(className, Constants.ClassFileVersion.of(8).MAJOR, Constants.ClassFileVersion.of(8).MINOR);
 
     // Disassemble method and check if Java 8 API is used as expected
     JavaClass javaClass;
index c1b0f8c44554be908a259f5d8864bce92bff23c8..abd9213f406774c63eb91001b610623e22cf9199 100644 (file)
@@ -16,6 +16,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava17Only;
  * @author Alexander Kriegisch
  */
 public class Java17PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava17Only {
+  private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(17);
 
   public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
     runTest("switch pattern matching error");
@@ -23,15 +24,15 @@ public class Java17PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava17Only
 
   public void testSwitchPatternMatchingJava() {
     runTest("switch pattern matching java");
-    checkVersion("SwitchPatternOK", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternOK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingAspect() {
     runTest("switch pattern matching aspect");
-    checkVersion("SwitchPatternAspect", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Application", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Shape", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("S", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternAspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("S", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public static Test suite() {
index a9c247dadc8a7daf8a3f57f9e25696d7bd1c7aa0..10363e9658b9504303fa50929f9f52687936e0e4 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater;
  */
 public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_17;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(17).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {
index 8afe68946f33851a3f7a7db04e6a98970206f95f..078a47671038ad4f43e7f414b844c4179efe7bc9 100644 (file)
@@ -16,6 +16,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava18Only;
  * @author Alexander Kriegisch
  */
 public class Java18PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava18Only {
+  private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(18);
 
   public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
     runTest("switch pattern matching error");
@@ -23,15 +24,15 @@ public class Java18PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava18Only
 
   public void testSwitchPatternMatchingJava() {
     runTest("switch pattern matching java");
-    checkVersion("SwitchPatternOK", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternOK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingAspect() {
     runTest("switch pattern matching aspect");
-    checkVersion("SwitchPatternAspect", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Application", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Shape", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("S", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternAspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("S", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingPreview2Error1() {
@@ -44,13 +45,13 @@ public class Java18PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava18Only
 
   public void testSwitchPatternMatchingPreview2Java() {
     runTest("switch pattern matching preview 2 java");
-    checkVersion("SwitchPatternPreview2OK", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternPreview2OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public void testSwitchPatternMatchingPreview2Aspect() {
     runTest("switch pattern matching preview 2 aspect");
-    checkVersion("SwitchPatternPreview2Aspect", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
-    checkVersion("Application", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION);
+    checkVersion("SwitchPatternPreview2Aspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
+    checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
   }
 
   public static Test suite() {
index a4c8ee9e25dd7837f7c5920ed9d14e7e2b35f78e..e2d308ab5c8211e9a1aed19eb555394b5f74fb1b 100644 (file)
@@ -21,7 +21,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava18OrLater;
  */
 public class SanityTestsJava18 extends XMLBasedAjcTestCaseForJava18OrLater {
 
-       public static final int bytecode_version_for_JDK_level = Constants.MAJOR_18;
+       public static final int bytecode_version_for_JDK_level = Constants.ClassFileVersion.of(18).MAJOR;
 
        // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
        public void testSimpleJava_A() {
@@ -73,7 +73,7 @@ public class SanityTestsJava18 extends XMLBasedAjcTestCaseForJava18OrLater {
        public void testVersionCorrect4() {
                runTest("simple - m");
                // Must be 49.0 when -1.5 is specified
-               checkVersion("A", Constants.MAJOR_1_5, 0);
+               checkVersion("A", Constants.ClassFileVersion.of(5).MAJOR, 0);
        }
 
        public static Test suite() {