Skip to content
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

java.lang.IllegalAccessError when matching refined type in App #5134

Closed
scabug opened this issue Nov 1, 2011 · 7 comments
Closed

java.lang.IllegalAccessError when matching refined type in App #5134

scabug opened this issue Nov 1, 2011 · 7 comments

Comments

@scabug
Copy link

scabug commented Nov 1, 2011

scala> object Test extends App {
     |   def b= new AnyRef {
     |     def a= ()
     |   }
     |   b.a match { case _ => () }
     | }
defined module Test

scala> Test
java.lang.IllegalAccessError: tried to access field Test$.reflParams$Cache1 from class Test$delayedInit$body
	at Test$delayedInit$body.<clinit>(<console>:11)
	at Test$.<init>(<console>:7)
	at Test$.<clinit>(<console>)
	at .<init>(<console>:9)
	at .<clinit>(<console>)
	at .<init>(<console>:11)
	at .<clinit>(<console>)
	at $export(<console>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:592)
	at scala.tools.nsc.interpreter.IMain$Request$$anonfun$10.apply(IMain.scala:828)
	at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
	at scala.tools.nsc.io.package$$anon$2.run(package.scala:31)
	at java.lang.Thread.run(Thread.java:662)

The same exception is thrown if the code is compiled and run.

@scabug
Copy link
Author

scabug commented Nov 1, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5134?orig=1
Reporter: @jsalvata
Assignee: @magarciaEPFL
Affected Versions: 2.9.0-1, 2.9.2, 2.10.4-RC1
See #5655
Attachments:

  • test.tar (created on Jan 30, 2013 4:47:10 AM UTC, 10240 bytes)

@scabug
Copy link
Author

scabug commented Jul 19, 2012

@odersky said:
It is one of several bugs having to do with DelayedInit. We will attempt a redesign using macros aftre 2.10.0 is out. Delaying until then.

@scabug
Copy link
Author

scabug commented Jan 30, 2013

Michael Purcell (mpurcell) said (edited on Jan 30, 2013 4:48:24 AM UTC):
Note: This was performed using 2.10.0-20121205-235900-18481cef9b and scala-2.10.0-SNAPSHOT when built using sbt.

Good afternoon, let me preface my comment by saying that I am new to the scala language, so I apologize anything I post is in bad form.

Anyway, I have been encountering the same problem with implicit definitions that have default parameters as such:

object Main extends App {
implicit def byteArrayImplicits(self: Array[Byte]) = new {
def someDefinition(aParameter: String = "With a default value"): String = "With value of " + aParameter
}
val result = "bytes".getBytes.someDefinition()
println("The result is: " + result);
}

After invokation the program crashes with (full stack trace available in attachment):
java.lang.IllegalAccessError: tried to access field Main$.reflParams$Cache1 from class Main$delayedInit$body
at Main$delayedInit$body.(main.scala:6)
at Main$.(main.scala:1)
... etc ...

I have attached the full source used to reproduce this problem.

Thanks,
Mike.

@scabug
Copy link
Author

scabug commented Mar 15, 2013

@adriaanm said:
Un-assigning to foster work stealing, as announced in https://groups.google.com/forum/?fromgroups=#!topic/scala-internals/o8WG4plpNkw

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

@scabug
Copy link
Author

scabug commented Jan 28, 2014

@adriaanm said:
the original report is fixed in 2.11.0-M8 (and M7, and possibly earlier):

Welcome to Scala version 2.11.0-M8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65).
Type in expressions to have them evaluated.
Type :help for more information.

scala> scala> object Test extends App {

// Detected repl transcript paste: ctrl-D to finish.

     |   def b= new AnyRef {
     |     def a= ()
     |   }
     |   b.a match { case _ => () }
     | }
defined module Test
 
scala> Test

// Replaying 2 commands from transcript.

scala> object Test extends App {
  def b= new AnyRef {
    def a= ()
  }
  b.a match { case _ => () }
}
warning: there were 1 feature warning(s); re-run with -feature for details
defined object Test

scala> Test
res0: Test.type = Test$@b08f1ce

@scabug scabug closed this as completed Jan 28, 2014
@scabug
Copy link
Author

scabug commented Feb 18, 2014

@retronym said:
Test case in scala/scala#3549. Assigning to Miguel to credit with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant