SI-7741: Be more tolerant of absent inner classfiles and non-Scala interface members#4386
Merged
lrytz merged 1 commit intoscala:2.11.xfrom Apr 9, 2015
Merged
SI-7741: Be more tolerant of absent inner classfiles and non-Scala interface members#4386lrytz merged 1 commit intoscala:2.11.xfrom
lrytz merged 1 commit intoscala:2.11.xfrom
Conversation
Member
|
/rebuild |
Member
|
@alewando I've squashed the commits together and tidied up the code a little. |
1. Avoid forcing info of non-Scala interface members
This avoids parsing the ostensibly malformed class definitions that
correspond to a Groovy lambda defined in an interface.
2. Be more tolerant of absent inner classfiles
Taking a leaf out of javac's book (see transcript below),
we can use stub symbols for InnerClass entries that don't
have corresponding class files on the compilation classpath.
This will limit failures to code that directly refers to the
inner class, rather than any code that simply refers to the
enclosing class.
It seems that groovyc has a habit of emitting incongrous
bytecode in this regard. But this change seems generally
useful.
```
% cat sandbox/{Test,Client}.java
public class Test {
public class Inner {}
}
public class Client {
public Test.Inner x() { return null; }
}
% javac -d . sandbox/Test.java && javac -classpath . sandbox/Client.java
% javac -d . sandbox/Test.java && rm 'Test$Inner.class' && javac -classpath . sandbox/Client.java
sandbox/Client.java:2: error: cannot access Inner
public Test.Inner x() { return null; }
^
class file for Test$Inner not found
1 error
% cat sandbox/{Test,Client}.java
public class Test {
public class Inner {}
}
public class Client {
public Test.NeverExisted x() { return null; }
}
% javac -classpath . sandbox/Client.java
sandbox/Client.java:2: error: cannot find symbol
public Test.NeverExisted x() { return null; }
^
symbol: class NeverExisted
location: class Test
1 error
% cat sandbox/{Test,Client}.java
public class Test {
public class Inner {}
}
public class Client {
public Test x() { return null; }
}
topic/groovy-interop ~/code/scala2 javac -d . sandbox/Test.java && rm 'Test$Inner.class' && javac -classpath . sandbox/Client.java # allowed
```
Member
|
/synch |
Member
|
Review by @lrytz |
Member
|
LGTM! |
lrytz
added a commit
that referenced
this pull request
Apr 9, 2015
SI-7741: Be more tolerant of absent inner classfiles and non-Scala interface members
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modifies ClassfileParser to avoid forcing the type information of members of non-Scala defined interfaces unnecessarily, and defers failures due to completely absent inner classes. Although these classes may not conform to expectations for javac-compiled classes, they are still valid JVM class files (in this case produced by the Groovy compiler) and should be supported by scalac. In addition to discussion on SI-7741 see also https://groups.google.com/d/msg/scala-internals/lGE15Ly6xHU/q1LLfS3w9R0J.