Skip to content

Commit 79426c9

Browse files
eed3si9nnevillelyh
authored andcommitted
Add JDK 9 constant types to the ClassfileParser
Fixes scala/bug#11635 Occasionally the compiler tries to parse the class files from the classpath. This happens, for example, during scaladoc comment referencing a class name `java.time.Instant`. This would cause error in JDK11 because it includes an unknown constant pool tag 9 (CONSTANT_Module). This updates the parser to skip it over.
1 parent 3fd7aec commit 79426c9

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ abstract class ClassfileParser {
177177
(u1: @switch) match {
178178
case CONSTANT_UTF8 | CONSTANT_UNICODE => in skip u2
179179
case CONSTANT_CLASS | CONSTANT_STRING | CONSTANT_METHODTYPE => in skip 2
180+
case CONSTANT_MODULE | CONSTANT_PACKAGE => in skip 2
180181
case CONSTANT_METHODHANDLE => in skip 3
181182
case CONSTANT_FIELDREF | CONSTANT_METHODREF | CONSTANT_INTFMETHODREF => in skip 4
182183
case CONSTANT_NAMEANDTYPE | CONSTANT_INTEGER | CONSTANT_FLOAT => in skip 4

src/reflect/scala/reflect/internal/ClassfileConstants.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ object ClassfileConstants {
7575
final val CONSTANT_METHODHANDLE = 15
7676
final val CONSTANT_METHODTYPE = 16
7777
final val CONSTANT_INVOKEDYNAMIC = 18
78+
final val CONSTANT_MODULE = 19
79+
final val CONSTANT_PACKAGE = 20
7880

7981
// tags describing the type of a literal in attribute values
8082
final val BYTE_TAG = 'B'

test/scaladoc/run/java-modules.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Text()
2+
Done.

test/scaladoc/run/java-modules.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import scala.tools.nsc.doc.model._
2+
import scala.tools.partest.ScaladocModelTest
3+
4+
object Test extends ScaladocModelTest {
5+
6+
override def code = """
7+
/**
8+
* @see [[toBytes(i:java\.time\.Instant* ]]
9+
*/
10+
class Foo
11+
"""
12+
13+
def scaladocSettings = ""
14+
15+
def testModel(root: Package) = {
16+
import access._
17+
val foo = root._class("Foo")
18+
println(foo.comment.get.short)
19+
}
20+
}

0 commit comments

Comments
 (0)