Skip to content

Commit

Permalink
[backport] Fix superclass for Java interface symbols created in JavaM…
Browse files Browse the repository at this point in the history
…irrors

According to the spec [1] the superclass of an interface is always
Object.

Restores the tests that were moved to pending in bf951ec,
fixex part of SI-9374.

[1] https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.1
  • Loading branch information
lrytz committed Jul 23, 2015
1 parent 1b57723 commit e511375
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ abstract class ClassfileParser {

def getType(index: Int): Type = getType(null, index)
def getType(sym: Symbol, index: Int): Type = sigToType(sym, getExternalName(index))
def getSuperClass(index: Int): Symbol = if (index == 0) AnyClass else getClassSymbol(index)
def getSuperClass(index: Int): Symbol = if (index == 0) AnyClass else getClassSymbol(index) // the only classfile that is allowed to have `0` in the super_class is java/lang/Object (see jvm spec)

private def createConstant(index: Int): Constant = {
val start = starts(index)
Expand Down
1 change: 1 addition & 0 deletions src/reflect/scala/reflect/runtime/JavaMirrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive
val ifaces = jclazz.getGenericInterfaces.toList map typeToScala
val isAnnotation = JavaAccFlags(jclazz).isAnnotation
if (isAnnotation) AnnotationClass.tpe :: ClassfileAnnotationClass.tpe :: ifaces
else if (jclazz.isInterface) ObjectTpe :: ifaces // interfaces have Object as superclass in the classfile (see jvm spec), but getGenericSuperclass seems to return null
else (if (jsuperclazz == null) AnyTpe else typeToScala(jsuperclazz)) :: ifaces
} finally {
parentsLevel -= 1
Expand Down

0 comments on commit e511375

Please sign in to comment.