-
Notifications
You must be signed in to change notification settings - Fork 21
Ignore inner class scanning in the compiler to support dynamic languages like groovy #7741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7741?orig=1 |
Gerrit Jansen van Vuuren (gerritjvv) said: Please note that the groovy code (in glue) mentioned above also uses the ignoreinnercls feature. |
Gerrit Jansen van Vuuren (gerritjvv) said: I've made a small project with the least possible code to show the error: https://github.com/gerritjvv/SI7741 I'm using: I've copied all of the jars (some are not relevant to the code) into the test-lib directory, it also contains the scala jars from my patched repo (https://github.com/gerritjvv/scala.git). Below are examples of two runs I've made: gvanvuuren@gvanvuuren-UX31E:~/checkouts/SI7741/si7741$ ./test.sh gvanvuuren@gvanvuuren-UX31E:~/checkouts/SI7741/si7741$ ./test.sh true |
@paulp said: If you have to mention groovy, you are approaching the problem at too high a layer. Here is what the jvm specification says, emphasis added.
|
Gerrit Jansen van Vuuren (gerritjvv) said: The classes adhere enough to the java spec to run and compile in the JVM, so I would assume that its ok. I've used the same classes from jython, jruby, clojure and javascript on the JVM without any errors. I think the basic issue here is that the scala compiler is stricter than the javac, although scala's strictness is a good thing there are times when you would want to have a flag to disable this strictness on inner classes (e.g. to use other non scala libraries), which otherwise would run perfectly on the JVM. I'll try to add in a javap and byte code representation of the classes before and after it gives the error. My first attempt at showing a possible solution is surely improvable, I don't think its a hack but just adding a flag on a feature that is part of the scalac. |
Gerrit Jansen van Vuuren (gerritjvv) said: --- This is MyModule without the AST transformations applied Classfile /home/gvanvuuren/checkouts/SI7741/si7741/testjars/MyModule.class
gvanvuuren@gvanvuuren-UX31E:~/checkouts/SI7741/si7741/testjars$ /opt/jdk1.7.0_21/bin/javap -c -s -l -v MyModule.class |
Gerrit Jansen van Vuuren (gerritjvv) said: I get [scalacfork] Compiling 2 files to /home/gvanvuuren/checkouts/scala-commit/scala/build/junit/classes I only really need to setup a test for ClassfileParser but its abstract and from the code its not quite clear how to implement it. Any pointers? |
@retronym said (edited on Mar 2, 2015 7:02:59 AM UTC): I have been looking into a similar issue, as reported https://groups.google.com/d/msg/scala-internals/lGE15Ly6xHU/q1LLfS3w9R0J It isn't quite the same issue as this one (in that report groovy emits the I have developed a fix that stops Scala from forcing the type information of members of non-Scala defined interfaces unnecessarily, and defers failures due to completely absent inner classes. https://github.com/retronym/scala/compare/ticket/7741 I'm going to ask Adam Lewandowski to pick up this branch and test out how it helps with groovy interop. If you're still interested in this issue, you might like to do the same. |
Gerrit Jansen van Vuuren (gerritjvv) said: |
Adam Lewandowski (alewando) said: |
Gerrit Jansen van Vuuren (gerritjvv) said: |
Adam Lewandowski (alewando) said: |
Adam Lewandowski (alewando) said: Should I go ahead and submit your branch as a pull request? |
@SethTisue said: |
Using java libraries that have been generated by languages like groovy where inner classes might not exist from scala causes the scala compiler to throw and error.
The only way to get around this is either remove the inner classes of the library generated during compile time and then put them back in during runtime, or ignore the exception in the scala compiler itself and continue with the class compilation.
The second option is much more integration friendly and if done via a settings flag can be turned on and off as required.
As an example see:
https://github.com/gerritjvv/glue/blob/master/core/glue-unit/src/main/groovy/org/glue/unit/om/impl/ScriptedGlueProcessImpl.groovy
From line 72.
The code I use actually use IMain from groovy, and example is pasted in below.
The text was updated successfully, but these errors were encountered: