You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but when run, it throws an IllegalAccessError (beforeHello! gets printed):
$ java -version
java version "1.6.0_24"OpenJDKRuntimeEnvironment (IcedTea61.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDKServerVM (build 20.0-b12, mixed mode)
$ scala Test
java.lang.IllegalAccessError: tried to access field Test$.reflParams$Cache1 from classTest$delayedInit$body
at Test$delayedInit$body.<clinit>(Test.scala:6)
at Test$.<init>(Test.scala:1)
at Test$.<clinit>(Test.scala)
at Test.main(Test.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88)
at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:56)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Note that with the last two lines replaced with
{code}...
println((1, 2) map (_ * 2))
{code}
or
{code}...
val (foo, bar) = (2, 4)
println((foo, bar))
{code}
or
{code}...
val intermediate = (1, 2) map (_ * 2)
val (foo, bar) = intermediate
println((foo, bar))
{code}
it prints (2,4) as expected. But when wrapped in a block
{code}...
{
val intermediate = (1, 2) map (_ * 2)
val (foo, bar) = intermediate
println((foo, bar))
}
{code}
or
{code}...
private val blah = {
val intermediate = (1, 2) map (_ * 2)
val (foo, bar) = intermediate
println((foo, bar))
}
{code}
it throws the exception.
Related
I described the issue at [http://stackoverflow.com/questions/11302291/why-does-this-scala-code-throw-illegalaccesserror-at-runtime]; reported here too since it seemed to be a compiler bug.
Possibly related to [#SI-5251].
The text was updated successfully, but these errors were encountered:
I have a simple application:
(The
t2mapper
is from Stack Overflow: [http://stackoverflow.com/a/4022510/319931].)The code compiles fine:
but when run, it throws an
IllegalAccessError
(beforeHello!
gets printed):Note that with the last two lines replaced with
{code}...
println((1, 2) map (_ * 2))
{code}
or
{code}...
val (foo, bar) = (2, 4)
println((foo, bar))
{code}
or
{code}...
val intermediate = (1, 2) map (_ * 2)
val (foo, bar) = intermediate
println((foo, bar))
{code}
it prints
(2,4)
as expected. But when wrapped in a block{code}...
{
val intermediate = (1, 2) map (_ * 2)
val (foo, bar) = intermediate
println((foo, bar))
}
{code}
or
{code}...
private val blah = {
val intermediate = (1, 2) map (_ * 2)
val (foo, bar) = intermediate
println((foo, bar))
}
{code}
it throws the exception.
Related
I described the issue at [http://stackoverflow.com/questions/11302291/why-does-this-scala-code-throw-illegalaccesserror-at-runtime]; reported here too since it seemed to be a compiler bug.
Possibly related to [#SI-5251].
The text was updated successfully, but these errors were encountered: