File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ package groovy
2020
2121import groovy.test.GroovyTestCase
2222import org.junit.jupiter.api.Test
23-
23+ import org.objectweb.asm.ClassReader
24+ import org.objectweb.asm.Opcodes
2425
2526class ClassTest {
2627
@@ -41,7 +42,18 @@ class ClassTest {
4142
4243 @Test
4344 void testClassesHaveSuperModiferSet () {
44- assert java.lang.reflect.Modifier . isSynchronized(this . class. modifiers)
45+ // ACC_SUPER (0x0020) is written into the .class file by Groovy's AsmClassGenerator
46+ // for every non-interface class. java.lang.reflect.Class.getModifiers() does NOT
47+ // expose it — bit 0x0020 is reused as ACC_SYNCHRONIZED for method modifiers — so
48+ // we inspect the raw bytecode access flags via ASM.
49+ //
50+ // ClassTest has Object as its implicit supertype;
51+ // GroovyTestCase has junit.framework.TestCase as its supertype.
52+ [ClassTest , GroovyTestCase ]. each { Class<?> clazz ->
53+ def stream = clazz. getResourceAsStream(" /${ clazz.name.replace('.', '/')} .class" )
54+ assert (new ClassReader (stream). access & Opcodes . ACC_SUPER ) != 0 ,
55+ " Expected ACC_SUPER to be set on ${ clazz.name} "
56+ }
4557 }
4658
4759}
You can’t perform that action at this time.
0 commit comments