From 7f9feba0213fc210c7752ab210f900c016032699 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 12 Apr 2013 13:38:42 -0700 Subject: [backport #1727] SI-7359 cyclic nested java class The original commit message (from 54a84a36d5): SI-6548 reflection correctly enters jinners When completing Java classes, runtime reflection enumerates their fields, methods, constructors and inner classes, loads them and enters them into either the instance part (ClassSymbol) or the static part (ModuleSymbol). However unlike fields, methods and constructors, inner classes don't need to be entered explicitly - they are entered implicitly when being loaded. This patch fixes the double-enter problem, make sure that enter-on-load uses the correct owner, and also hardens jclassAsScala against double enters that can occur in a different scenario. --- test/files/run/t6989.check | 84 ++++------------------------------- test/files/run/t6989/JavaClass_1.java | 2 + test/files/run/t7359.check | 1 + test/files/run/t7359/Cyclic_1.java | 3 ++ test/files/run/t7359/Test_2.scala | 6 +++ 5 files changed, 21 insertions(+), 75 deletions(-) create mode 100644 test/files/run/t7359.check create mode 100644 test/files/run/t7359/Cyclic_1.java create mode 100644 test/files/run/t7359/Test_2.scala (limited to 'test/files/run') diff --git a/test/files/run/t6989.check b/test/files/run/t6989.check index 3a94f6e8df..8943792115 100644 --- a/test/files/run/t6989.check +++ b/test/files/run/t6989.check @@ -113,18 +113,6 @@ isProtected = false isPublic = false privateWithin = ============ -sym = class $PrivateJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 -isPrivate = true -isProtected = false -isPublic = false -privateWithin = -============ -sym = value this$0, signature = foo.JavaClass_1, owner = class $PrivateJavaClass -isPrivate = false -isProtected = false -isPublic = false -privateWithin = package foo -============ sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = false isProtected = true @@ -143,18 +131,6 @@ isProtected = false isPublic = false privateWithin = package foo ============ -sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 -isPrivate = false -isProtected = true -isPublic = false -privateWithin = package foo -============ -sym = value this$0, signature = foo.JavaClass_1, owner = class $ProtectedJavaClass -isPrivate = false -isProtected = false -isPublic = false -privateWithin = package foo -============ sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = false isProtected = false @@ -179,97 +155,55 @@ isProtected = false isPublic = true privateWithin = ============ -sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 -isPrivate = false -isProtected = false -isPublic = true -privateWithin = -============ -sym = constructor $PublicJavaClass, signature = (x$1: foo.JavaClass_1)JavaClass_1.this.$PublicJavaClass, owner = class $PublicJavaClass +sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = value this$0, signature = foo.JavaClass_1, owner = class $PublicJavaClass -isPrivate = false -isProtected = false -isPublic = false -privateWithin = package foo -============ -sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 +sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = object PrivateStaticJavaClass, signature = JavaClass_1.this.PrivateStaticJavaClass.type, owner = class JavaClass_1 +sym = object PrivateStaticJavaClass, signature = foo.JavaClass_1.PrivateStaticJavaClass.type, owner = object JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = object ProtectedStaticJavaClass, signature = JavaClass_1.this.ProtectedStaticJavaClass.type, owner = class JavaClass_1 +sym = object ProtectedStaticJavaClass, signature = foo.JavaClass_1.ProtectedStaticJavaClass.type, owner = object JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 -isPrivate = false -isProtected = false -isPublic = true -privateWithin = -============ -sym = constructor PublicStaticJavaClass, signature = ()JavaClass_1.this.PublicStaticJavaClass, owner = class PublicStaticJavaClass -isPrivate = false -isProtected = false -isPublic = true -privateWithin = -============ -sym = object PublicStaticJavaClass, signature = JavaClass_1.this.PublicStaticJavaClass.type, owner = class JavaClass_1 +sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo -isPrivate = false -isProtected = false -isPublic = true -privateWithin = -============ -sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 -isPrivate = true -isProtected = false -isPublic = false -privateWithin = -============ -sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 -isPrivate = true -isProtected = false -isPublic = false -privateWithin = -============ -sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +sym = constructor PublicStaticJavaClass, signature = ()foo.JavaClass_1.PublicStaticJavaClass, owner = class PublicStaticJavaClass isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = constructor PublicStaticJavaClass, signature = ()JavaClass_1.this.PublicStaticJavaClass, owner = class PublicStaticJavaClass +sym = object PublicStaticJavaClass, signature = foo.JavaClass_1.PublicStaticJavaClass.type, owner = object JavaClass_1 isPrivate = false isProtected = false isPublic = true diff --git a/test/files/run/t6989/JavaClass_1.java b/test/files/run/t6989/JavaClass_1.java index eb26a08700..72ec4d6ab6 100644 --- a/test/files/run/t6989/JavaClass_1.java +++ b/test/files/run/t6989/JavaClass_1.java @@ -7,6 +7,8 @@ package foo; // I'm leaving the incorrect results of FromJavaClassCompleters in the check // file, so that we get notified when something changes there. +// ^^^ It's not clear what those incorrect results were, but the fix for SI-7359 +// (backport of fix for SI-6548) has probably resolved some of these. OP, please revisit this comment. class PackagePrivateJavaClass { private int privateField = 0; diff --git a/test/files/run/t7359.check b/test/files/run/t7359.check new file mode 100644 index 0000000000..9766475a41 --- /dev/null +++ b/test/files/run/t7359.check @@ -0,0 +1 @@ +ok diff --git a/test/files/run/t7359/Cyclic_1.java b/test/files/run/t7359/Cyclic_1.java new file mode 100644 index 0000000000..42b46c1aed --- /dev/null +++ b/test/files/run/t7359/Cyclic_1.java @@ -0,0 +1,3 @@ +abstract class Cyclic { + static interface Inner { } +} \ No newline at end of file diff --git a/test/files/run/t7359/Test_2.scala b/test/files/run/t7359/Test_2.scala new file mode 100644 index 0000000000..bb6f4cb2d9 --- /dev/null +++ b/test/files/run/t7359/Test_2.scala @@ -0,0 +1,6 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + typeOf[Cyclic].members + println("ok") +} \ No newline at end of file -- cgit v1.2.3