File tree Expand file tree Collapse file tree
test/junit/scala/tools/nsc/backend/jvm Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package scala .tools .nsc .backend .jvm
2+
3+ import org .junit .Assert .assertEquals
4+ import org .junit .Test
5+
6+ import java .lang .reflect .Member
7+
8+ class ClassfileParserTest {
9+ @ Test
10+ def noConstantPoolLag (): Unit = {
11+ def constNames (ms : List [Member ]) = ms.collect {
12+ case f if f.getName.startsWith(" CONSTANT_" ) => f.getName
13+ }.sorted
14+
15+ val toScalac = Map (
16+ " CONSTANT_INTERFACE_METHODREF" -> " CONSTANT_INTFMETHODREF" ,
17+ " CONSTANT_INVOKE_DYNAMIC" -> " CONSTANT_INVOKEDYNAMIC" ,
18+ " CONSTANT_METHOD_HANDLE" -> " CONSTANT_METHODHANDLE" ,
19+ " CONSTANT_METHOD_TYPE" -> " CONSTANT_METHODTYPE" ,
20+ " CONSTANT_NAME_AND_TYPE" -> " CONSTANT_NAMEANDTYPE" ,
21+ ).withDefault(x => x)
22+
23+ val asmConsts = constNames(Class .forName(" scala.tools.asm.Symbol" ).getDeclaredFields.toList)
24+ .map(_.stripSuffix(" _TAG" ))
25+ .map(toScalac)
26+ .:: (" CONSTANT_UNICODE" )
27+ .sorted
28+ val scalacConsts = constNames(scala.reflect.internal.ClassfileConstants .getClass.getDeclaredMethods.toList)
29+ assertEquals(scalacConsts, asmConsts)
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments