Skip to content

Commit 566c0de

Browse files
committed
fix broken test
1 parent 17d1ce0 commit 566c0de

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/test/groovy/groovy/ClassTest.groovy

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ package groovy
2020

2121
import groovy.test.GroovyTestCase
2222
import org.junit.jupiter.api.Test
23-
23+
import org.objectweb.asm.ClassReader
24+
import org.objectweb.asm.Opcodes
2425

2526
class 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
}

0 commit comments

Comments
 (0)