]> source.dussan.org Git - aspectj.git/commitdiff
Use relocated ASM class names in BCException message
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 4 Aug 2023 02:31:31 +0000 (09:31 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 4 Aug 2023 02:31:31 +0000 (09:31 +0700)
Fixes #251.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java

index 3feadca38f3589065fa6f631fd8ec65cf75febd6..61ebfb7cff01921f73fd0dcb2c2b7308cd3148f4 100644 (file)
@@ -753,11 +753,14 @@ public final class LazyClassGen {
                // are required (unless turning off the verifier)
                if ((myGen.getMajor() == Constants.MAJOR_1_6 && world.shouldGenerateStackMaps()) || myGen.getMajor() > Constants.MAJOR_1_6) {
                        if (!AsmDetector.isAsmAround) {
-                               throw new BCException(
-                                       "Unable to find ASM classes (" + AsmDetector.CLASS_READER + ", " + AsmDetector.CLASS_VISITOR + ") " +
-                                               "for stackmap generation. Stackmap generation for woven code is required to avoid verify errors " +
-                                               "on a Java 1.7 or higher runtime.", AsmDetector.reasonAsmIsMissing
-                               );
+                               // Fix https://github.com/eclipse-aspectj/aspectj/issues/251, using "replace('Ä', 'Ö')" to avoid non-relocated
+                               // class names to be embedded into the error message during compile time, making it end up in the class constant
+                               // pool unwantedly, as this clashes with post-compile ASM package relocation.
+                               final String errorMessage = "Unable to find ASM classes (" +
+                                       AsmDetector.CLASS_READER.replace('Ä', 'Ö') + ", " + AsmDetector.CLASS_VISITOR.replace('Ä', 'Ö') + ") " +
+                                       "for stackmap generation. Stackmap generation for woven code is required to avoid verify errors " +
+                                       "on a Java 1.7 or higher runtime.";
+                               throw new BCException(errorMessage, AsmDetector.reasonAsmIsMissing);
                        }
                        wovenClassFileData = StackMapAdder.addStackMaps(world, myGen.getClassName(), wovenClassFileData);
                }