-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix reflective toolbox producing invalid bytecode #44
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
Merged
Conversation
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
Wrapper method for AST undergoing a reflective compilation has been incorrectly marked as static. This was off the radars until one day the code being compiled declared a top-level method. During flatten that method got hoisted into the wrapper module, and its invocation got translated into an instance call upon the module. This led to static wrapper method trying to call an instance method, and that blew up the bytecode verifier. More info: https://issues.scala-lang.org/browse/SI-5266. Fixes SI-5266, review by @odersky.
gkossakowski
added a commit
to gkossakowski/scala
that referenced
this pull request
Jan 11, 2012
Merge latest changes from trunk
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 22, 2015
used revision: scala/scala-java8-compat@9253ed9e7a demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 23, 2015
used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 23, 2015
used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 23, 2015
used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 23, 2015
including LambdaDeserializer used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
retronym
referenced
this pull request
in retronym/scala
Jun 25, 2015
And also embed LambdaDeserializer used revision: scala/scala-java8-compat@9253ed9 demo: ``` % ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic #44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast #46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic #34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn ```
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 30, 2015
including LambdaDeserializer used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 30, 2015
including LambdaDeserializer used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 30, 2015
including LambdaDeserializer used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
lrytz
added a commit
to lrytz/scala
that referenced
this pull request
Jun 30, 2015
including LambdaDeserializer used revision: scala/scala-java8-compat@9253ed9 demo: ant -Dlocker.skip=1 build/quick/bin/scala -Ydelambdafy:method -Ybackend:GenBCode -Yopt:closure-elimination -target:jvm-1.8 scala> class C { def f = {val f: Int => Int = x => x + 1; f(10) } } scala> :javap C public int f(); 0: invokedynamic scala#44, 0 // InvokeDynamic #0:apply$mcII$sp:()Lscala/compat/java8/JFunction1$mcII$sp; 5: checkcast scala#46 // class scala/Function1 8: astore_1 9: aload_1 10: bipush 10 12: istore_2 13: pop 14: iload_2 15: invokestatic scala#34 // Method $line3$$read$C$$$anonfun$1:(I)I 18: ireturn
da-liii
pushed a commit
to da-liii/scala
that referenced
this pull request
Nov 11, 2018
Alkimia frameworks branch was merged into master
bishabosha
added a commit
to bishabosha/scala
that referenced
this pull request
Feb 20, 2020
Add `@compileTimeOnly` annotation to unpickled inline def definitions
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.
Wrapper method for AST undergoing a reflective compilation
has been incorrectly marked as static.
This was off the radars until one day the code being compiled declared
a top-level method. During flatten that method got hoisted into the
wrapper module, and its invocation got translated into an instance
call upon the module. This led to static wrapper method trying to call
an instance method, and that blew up the bytecode verifier. More info:
https://issues.scala-lang.org/browse/SI-5266.
Fixes SI-5266, review by @odersky.