From 4ff1738770de7eb38b54e32cfe9b0594bdb97d29 Mon Sep 17 00:00:00 2001 From: Eric Bruneton Date: Sun, 12 Jun 2022 11:17:35 +0200 Subject: [PATCH 1/3] Make sure that CheckClassAdapter leaves classes unchanged. Also fix a bug in Analyzer which was not computing the optimal maxLocals value for static methods. --- .../objectweb/asm/tree/analysis/Analyzer.java | 3 ++ .../AnalyzerWithBasicInterpreterTest.java | 22 +++++++++++++ .../main/resources/jdk11/AllStructures.class | Bin 232 -> 232 bytes .../resources/java/jdk11/AllStructures.jasm | 3 +- .../asm/util/CheckMethodAdapter.java | 4 +++ .../asm/util/CheckClassAdapterTest.java | 29 ++++++++++++++++-- .../test/resources/jdk11.AllStructures.txt | 4 +-- .../org/objectweb/asm/ClassWriterTest.java | 13 +++++--- 8 files changed, 69 insertions(+), 9 deletions(-) diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java index f22e9b0f8..7aad8db52 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java @@ -305,6 +305,9 @@ public class Analyzer implements Opcodes { */ private static int computeMaxLocals(final MethodNode method) { int maxLocals = Type.getArgumentsAndReturnSizes(method.desc) >> 2; + if ((method.access & Opcodes.ACC_STATIC) != 0) { + maxLocals -= 1; + } for (AbstractInsnNode insnNode : method.instructions) { if (insnNode instanceof VarInsnNode) { int local = ((VarInsnNode) insnNode).var; diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java index 6cefb4d43..968515da0 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java @@ -33,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.IOException; import java.nio.file.Files; @@ -45,6 +46,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; +import org.objectweb.asm.test.AsmTest.PrecompiledClass; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; @@ -138,12 +140,32 @@ class AnalyzerWithBasicInterpreterTest extends AsmTest { analyzedMethodMaxs.add(new MethodMaxs(methodNode.maxStack, methodNode.maxLocals)); } + // jdk11.AllStructures has non optimal max stack and max local values on purpose. + assumeTrue(classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES); for (int i = 0; i < analyzedMethodMaxs.size(); ++i) { assertTrue(analyzedMethodMaxs.get(i).maxLocals >= methodMaxs.get(i).maxLocals); assertTrue(analyzedMethodMaxs.get(i).maxStack >= methodMaxs.get(i).maxStack); } } + /** + * Tests that analyzeAndComputeMaxs computes the smallest possible maxLocals for static methods. + * + * @throws AnalyzerException if the test class can't be analyzed. + */ + @Test + void testAnalyzeAndComputeMaxs_staticMethod() throws AnalyzerException { + MethodNode methodNode = + new MethodNodeBuilder("(I)V", /* maxStack = */ 0, /* maxLocals = */ 0).vreturn().build(); + methodNode.access |= Opcodes.ACC_STATIC; + Analyzer analyzer = new Analyzer(new BasicInterpreter()); + + analyzer.analyzeAndComputeMaxs("C", methodNode); + + assertEquals(1, methodNode.maxLocals); + assertEquals(0, methodNode.maxStack); + } + /** * Tests that the analyzer does not loop infinitely, even if the {@link Interpreter#merge} method * does not follow its required contract (namely that if the merge result is equal to the first diff --git a/asm-test/src/main/resources/jdk11/AllStructures.class b/asm-test/src/main/resources/jdk11/AllStructures.class index 3aa1138bf4b74d8637e96d3fb9fb946fb1aedb7e..dcb51aa5f7bb41ecd1e85fac39476e121b086eca 100644 GIT binary patch delta 13 UcmaFC_=0i55oRU^=84A@0VJXXr~m)} delta 13 UcmaFC_=0i55oSgP#)-!j0VI?Jr2qf` diff --git a/asm-test/src/resources/java/jdk11/AllStructures.jasm b/asm-test/src/resources/java/jdk11/AllStructures.jasm index ecc72c7b2..cafff1059 100644 --- a/asm-test/src/resources/java/jdk11/AllStructures.jasm +++ b/asm-test/src/resources/java/jdk11/AllStructures.jasm @@ -42,7 +42,8 @@ super public class AllStructures public Method "":"()V" - stack 1 locals 1 + // Valid but non optimal max_stack and max_locals, on purpose (to test cases like this). + stack 2 locals 3 { aload_0; invokespecial Method java/lang/Object."":"()V"; diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java index 8b4ba7a92..6dc2e5832 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java @@ -446,6 +446,8 @@ public class CheckMethodAdapter extends MethodVisitor { new MethodNode(api, access, name, descriptor, null, null) { @Override public void visitEnd() { + int originalMaxLocals = maxLocals; + int originalMaxStack = maxStack; boolean checkMaxStackAndLocals = false; boolean checkFrames = false; if (methodVisitor instanceof MethodWriterWrapper) { @@ -473,6 +475,8 @@ public class CheckMethodAdapter extends MethodVisitor { throwError(analyzer, e); } if (methodVisitor != null) { + maxLocals = originalMaxLocals; + maxStack = originalMaxStack; accept(methodVisitor); } } diff --git a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java index 4206bbcd5..280ec6286 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java @@ -468,7 +468,7 @@ class CheckClassAdapterTest extends AsmTest implements Opcodes { */ @ParameterizedTest @MethodSource(ALL_CLASSES_AND_ALL_APIS) - void testVisitMethods_precompiledClass( + void testVisitMethods_classWriterDelegate_precompiledClass( final PrecompiledClass classParameter, final Api apiParameter) { byte[] classFile = classParameter.getBytes(); ClassReader classReader = new ClassReader(classFile); @@ -481,7 +481,32 @@ class CheckClassAdapterTest extends AsmTest implements Opcodes { Exception exception = assertThrows(UnsupportedOperationException.class, accept); assertTrue(exception.getMessage().matches(UNSUPPORTED_OPERATION_MESSAGE_PATTERN)); } else { - classReader.accept(classVisitor, attributes(), 0); + assertDoesNotThrow(accept); + assertEquals(new ClassFile(classFile), new ClassFile(classWriter.toByteArray())); + } + } + + /** + * Tests that classes are unchanged with a ClassReader->CheckClassAdapter->ClassVisitor transform. + */ + @ParameterizedTest + @MethodSource(ALL_CLASSES_AND_ALL_APIS) + void testVisitMethods_nonClassWriterDelegate_precompiledClass( + final PrecompiledClass classParameter, final Api apiParameter) { + byte[] classFile = classParameter.getBytes(); + ClassReader classReader = new ClassReader(classFile); + ClassWriter classWriter = new ClassWriter(0); + ClassVisitor noOpClassVisitor = + new ClassVisitor(/* latest */ Opcodes.ASM10_EXPERIMENTAL, classWriter) {}; + ClassVisitor classVisitor = new CheckClassAdapter(apiParameter.value(), noOpClassVisitor, true); + + Executable accept = () -> classReader.accept(classVisitor, attributes(), 0); + + if (classParameter.isMoreRecentThan(apiParameter)) { + Exception exception = assertThrows(UnsupportedOperationException.class, accept); + assertTrue(exception.getMessage().matches(UNSUPPORTED_OPERATION_MESSAGE_PATTERN)); + } else { + assertDoesNotThrow(accept); assertEquals(new ClassFile(classFile), new ClassFile(classWriter.toByteArray())); } } diff --git a/asm-util/src/test/resources/jdk11.AllStructures.txt b/asm-util/src/test/resources/jdk11.AllStructures.txt index 9b68bc9c1..98027a1e2 100644 --- a/asm-util/src/test/resources/jdk11.AllStructures.txt +++ b/asm-util/src/test/resources/jdk11.AllStructures.txt @@ -10,6 +10,6 @@ public class jdk11/AllStructures { ALOAD 0 INVOKESPECIAL java/lang/Object. ()V RETURN - MAXSTACK = 1 - MAXLOCALS = 1 + MAXSTACK = 2 + MAXLOCALS = 3 } diff --git a/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java b/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java index 22afbd4bb..d5c2e0126 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java @@ -556,11 +556,13 @@ class ClassWriterTest extends AsmTest { /** * Tests that a ClassReader -> ClassWriter transform with the COMPUTE_MAXS option leaves classes * unchanged. This is not true in general (the valid max stack and max locals for a given method - * are not unique), but this should be the case with our precompiled classes. + * are not unique), but this should be the case with our precompiled classes (except + * jdk11.AllStructures, which has non optimal max values on purpose). */ @ParameterizedTest @MethodSource(ALL_CLASSES_AND_ALL_APIS) void testReadAndWrite_computeMaxs(final PrecompiledClass classParameter, final Api apiParameter) { + assumeTrue(classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES); byte[] classFile = classParameter.getBytes(); ClassReader classReader = new ClassReader(classFile); ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); @@ -614,8 +616,10 @@ class ClassWriterTest extends AsmTest { assertTrue(classWriter.hasFlags(ClassWriter.COMPUTE_FRAMES)); // The computed stack map frames should be equal to the original ones, if any (classes before // JDK8 don't have ones). This is not true in general (the valid frames for a given method are - // not unique), but this should be the case with our precompiled classes. - if (classParameter.isMoreRecentThan(Api.ASM4)) { + // not unique), but this should be the case with our precompiled classes (except + // jdk11.AllStructures, which has non optimal max values on purpose). + if (classParameter.isMoreRecentThan(Api.ASM4) + && classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES) { assertEquals(new ClassFile(classFile), new ClassFile(newClassFile)); } Executable newInstance = () -> new ClassFile(newClassFile).newInstance(); @@ -664,7 +668,8 @@ class ClassWriterTest extends AsmTest { // The computed stack map frames should be equal to the original ones, if any (classes before // JDK8 don't have ones). This is not true in general (the valid frames for a given method are // not unique), but this should be the case with our precompiled classes. - if (classParameter.isMoreRecentThan(Api.ASM4)) { + if (classParameter.isMoreRecentThan(Api.ASM4) + && classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES) { assertEquals(new ClassFile(classFile), new ClassFile(newClassFile)); } Executable newInstance = () -> new ClassFile(newClassFile).newInstance(); -- GitLab From c1d3cd1fcd074ad1cdfc9cc48f866818448643b3 Mon Sep 17 00:00:00 2001 From: Eric Bruneton Date: Sun, 12 Jun 2022 16:46:22 +0200 Subject: [PATCH 2/3] Take code review comments into account. --- .../AnalyzerWithBasicInterpreterTest.java | 4 +- .../java/org/objectweb/asm/test/AsmTest.java | 1 + .../main/resources/jdk11/AllStructures.class | Bin 232 -> 232 bytes .../jdk3/SubOptimalMaxStackAndLocals.class | Bin 0 -> 203 bytes .../resources/java/jdk11/AllStructures.jasm | 5 +- .../jdk3/SubOptimalMaxStackAndLocals.jasm | 50 ++++++++++++++++++ .../test/resources/jdk11.AllStructures.txt | 4 +- .../jdk3.SubOptimalMaxStackAndLocals.txt | 14 +++++ .../org/objectweb/asm/ClassWriterTest.java | 13 ++--- 9 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 asm-test/src/main/resources/jdk3/SubOptimalMaxStackAndLocals.class create mode 100644 asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm create mode 100644 asm-util/src/test/resources/jdk3.SubOptimalMaxStackAndLocals.txt diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java index 968515da0..fc1999344 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java @@ -140,8 +140,8 @@ class AnalyzerWithBasicInterpreterTest extends AsmTest { analyzedMethodMaxs.add(new MethodMaxs(methodNode.maxStack, methodNode.maxLocals)); } - // jdk11.AllStructures has non optimal max stack and max local values on purpose. - assumeTrue(classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES); + // jdk3.SubOptimalMaxStackAndLocals has non optimal max stack and max local values on purpose. + assumeTrue(classParameter != PrecompiledClass.JDK3_SUB_OPTIMAL_MAX_STACK_AND_LOCALS); for (int i = 0; i < analyzedMethodMaxs.size(); ++i) { assertTrue(analyzedMethodMaxs.get(i).maxLocals >= methodMaxs.get(i).maxLocals); assertTrue(analyzedMethodMaxs.get(i).maxStack >= methodMaxs.get(i).maxStack); diff --git a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java index 48eb1863e..ee0ad0994 100644 --- a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java +++ b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java @@ -143,6 +143,7 @@ public abstract class AsmTest { JDK3_ARTIFICIAL_STRUCTURES("jdk3.ArtificialStructures"), JDK3_INNER_CLASS("jdk3.AllStructures$InnerClass"), JDK3_LARGE_METHOD("jdk3.LargeMethod"), + JDK3_SUB_OPTIMAL_MAX_STACK_AND_LOCALS("jdk3.SubOptimalMaxStackAndLocals"), JDK5_ALL_INSTRUCTIONS("jdk5.AllInstructions"), JDK5_ALL_STRUCTURES("jdk5.AllStructures"), JDK5_ANNOTATION("jdk5.AllStructures$InvisibleAnnotation"), diff --git a/asm-test/src/main/resources/jdk11/AllStructures.class b/asm-test/src/main/resources/jdk11/AllStructures.class index dcb51aa5f7bb41ecd1e85fac39476e121b086eca..3aa1138bf4b74d8637e96d3fb9fb946fb1aedb7e 100644 GIT binary patch delta 13 UcmaFC_=0i55oSgP#)-!j0VI?Jr2qf` delta 13 UcmaFC_=0i55oRU^=84A@0VJXXr~m)} diff --git a/asm-test/src/main/resources/jdk3/SubOptimalMaxStackAndLocals.class b/asm-test/src/main/resources/jdk3/SubOptimalMaxStackAndLocals.class new file mode 100644 index 0000000000000000000000000000000000000000..b494edc31cdffd57ccb37f3bd60af6b4fe07a100 GIT binary patch literal 203 zcmX^0Z`VEs1_pfw9xeuE1~zsE7Ip?!Mh1nflx$=D;L;@jf|AVK#2nwmir|vOh z6rcR$#GGPA27#=^vPAuy#JqHU|D>$c_5NIxtpq2jDs+Zh-)LKUzB IX(k2^0DKfJ0{{R3 literal 0 HcmV?d00001 diff --git a/asm-test/src/resources/java/jdk11/AllStructures.jasm b/asm-test/src/resources/java/jdk11/AllStructures.jasm index cafff1059..61fcb028d 100644 --- a/asm-test/src/resources/java/jdk11/AllStructures.jasm +++ b/asm-test/src/resources/java/jdk11/AllStructures.jasm @@ -29,7 +29,7 @@ package jdk11; /** * A class with JDK11 specific class file feature. A corresponding class file can be generated - with the OpenJDK asmtools (https://wiki.openjdk.java.net/display/CodeTools/asmtools), + * with the OpenJDK asmtools (https://wiki.openjdk.java.net/display/CodeTools/asmtools), * version 7 or more. Usage: * * java -jar asmtools.jar jasm AllStructures.jasm @@ -42,8 +42,7 @@ super public class AllStructures public Method "":"()V" - // Valid but non optimal max_stack and max_locals, on purpose (to test cases like this). - stack 2 locals 3 + stack 1 locals 1 { aload_0; invokespecial Method java/lang/Object."":"()V"; diff --git a/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm b/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm new file mode 100644 index 000000000..6a2c8db67 --- /dev/null +++ b/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm @@ -0,0 +1,50 @@ +// ASM: a very small and fast Java bytecode manipulation framework +// Copyright (c) 2000-2011 INRIA, France Telecom +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holders nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +package jdk3; + +/** + * A class with valid but non optimal max_stack and max_locals, on purpose (to test cases like + * this). A corresponding class file can be generated with the OpenJDK asmtools + * (https://wiki.openjdk.java.net/display/CodeTools/asmtools), version 7 or more. Usage: + * + * java -jar asmtools.jar jasm AllStructures.jasm + * + * @author Eric Bruneton + */ +super public class SubOptimalMaxStackAndLocals + version 47:0 +{ + +public Method "":"()V" + stack 2 locals 3 +{ + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; +} +} // end Class SubOptimalMaxStackAndLocals diff --git a/asm-util/src/test/resources/jdk11.AllStructures.txt b/asm-util/src/test/resources/jdk11.AllStructures.txt index 98027a1e2..9b68bc9c1 100644 --- a/asm-util/src/test/resources/jdk11.AllStructures.txt +++ b/asm-util/src/test/resources/jdk11.AllStructures.txt @@ -10,6 +10,6 @@ public class jdk11/AllStructures { ALOAD 0 INVOKESPECIAL java/lang/Object. ()V RETURN - MAXSTACK = 2 - MAXLOCALS = 3 + MAXSTACK = 1 + MAXLOCALS = 1 } diff --git a/asm-util/src/test/resources/jdk3.SubOptimalMaxStackAndLocals.txt b/asm-util/src/test/resources/jdk3.SubOptimalMaxStackAndLocals.txt new file mode 100644 index 000000000..c349b069e --- /dev/null +++ b/asm-util/src/test/resources/jdk3.SubOptimalMaxStackAndLocals.txt @@ -0,0 +1,14 @@ +// class version 47.0 (47) +// access flags 0x21 +public class jdk3/SubOptimalMaxStackAndLocals { + + // compiled from: SubOptimalMaxStackAndLocals.jasm + + // access flags 0x1 + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + MAXSTACK = 2 + MAXLOCALS = 3 +} diff --git a/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java b/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java index d5c2e0126..0871e90c2 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java @@ -557,12 +557,12 @@ class ClassWriterTest extends AsmTest { * Tests that a ClassReader -> ClassWriter transform with the COMPUTE_MAXS option leaves classes * unchanged. This is not true in general (the valid max stack and max locals for a given method * are not unique), but this should be the case with our precompiled classes (except - * jdk11.AllStructures, which has non optimal max values on purpose). + * jdk3.SubOptimalMaxStackAndLocals, which has non optimal max values on purpose). */ @ParameterizedTest @MethodSource(ALL_CLASSES_AND_ALL_APIS) void testReadAndWrite_computeMaxs(final PrecompiledClass classParameter, final Api apiParameter) { - assumeTrue(classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES); + assumeTrue(classParameter != PrecompiledClass.JDK3_SUB_OPTIMAL_MAX_STACK_AND_LOCALS); byte[] classFile = classParameter.getBytes(); ClassReader classReader = new ClassReader(classFile); ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); @@ -617,9 +617,9 @@ class ClassWriterTest extends AsmTest { // The computed stack map frames should be equal to the original ones, if any (classes before // JDK8 don't have ones). This is not true in general (the valid frames for a given method are // not unique), but this should be the case with our precompiled classes (except - // jdk11.AllStructures, which has non optimal max values on purpose). + // jdk3.SubOptimalMaxStackAndLocals, which has non optimal max values on purpose). if (classParameter.isMoreRecentThan(Api.ASM4) - && classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES) { + && classParameter != PrecompiledClass.JDK3_SUB_OPTIMAL_MAX_STACK_AND_LOCALS) { assertEquals(new ClassFile(classFile), new ClassFile(newClassFile)); } Executable newInstance = () -> new ClassFile(newClassFile).newInstance(); @@ -667,9 +667,10 @@ class ClassWriterTest extends AsmTest { // The computed stack map frames should be equal to the original ones, if any (classes before // JDK8 don't have ones). This is not true in general (the valid frames for a given method are - // not unique), but this should be the case with our precompiled classes. + // not unique), but this should be the case with our precompiled classes (except + // jdk3.SubOptimalMaxStackAndLocals, which has non optimal max values on purpose). if (classParameter.isMoreRecentThan(Api.ASM4) - && classParameter != PrecompiledClass.JDK11_ALL_STRUCTURES) { + && classParameter != PrecompiledClass.JDK3_SUB_OPTIMAL_MAX_STACK_AND_LOCALS) { assertEquals(new ClassFile(classFile), new ClassFile(newClassFile)); } Executable newInstance = () -> new ClassFile(newClassFile).newInstance(); -- GitLab From 1b7ad30d6be65b89356a169dc0d8bf5a7646099d Mon Sep 17 00:00:00 2001 From: Eric Bruneton Date: Sun, 12 Jun 2022 16:52:25 +0200 Subject: [PATCH 3/3] Fix copy/paste error. --- .../src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm b/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm index 6a2c8db67..7e21bb5f7 100644 --- a/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm +++ b/asm-test/src/resources/java/jdk3/SubOptimalMaxStackAndLocals.jasm @@ -32,7 +32,7 @@ package jdk3; * this). A corresponding class file can be generated with the OpenJDK asmtools * (https://wiki.openjdk.java.net/display/CodeTools/asmtools), version 7 or more. Usage: * - * java -jar asmtools.jar jasm AllStructures.jasm + * java -jar asmtools.jar jasm SubOptimalMaxStackAndLocals.jasm * * @author Eric Bruneton */ -- GitLab