-
-
Notifications
You must be signed in to change notification settings - Fork 646
IllegalAccessError: tried to access class io.vavr.Lambda from class Main$ #2337
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
I noticed that this error does not occur with older Scala versions, like |
Hi, thank you for reporting the issue!
Does the error also occur with Scala 2.13.0-M5? Thanks! |
Yes, same error with |
Thank you for your feedback, that helps! Btw - I did not know about I could reproduce the problem but I needed to tweak your scripts a bit: - scalac -d out -classpath (coursier fetch io.vavr:vavr:0.9.3 | paste -s -d:) Main.scala
+ scalac -d out -classpath "$(coursier fetch -p io.vavr:vavr:0.9.3)" Main.scala
- scala -d out -classpath out:(coursier fetch io.vavr:vavr:0.9.3 | paste -s -d:) Main
+ scala -d out -classpath out:"$(coursier fetch -p io.vavr:vavr:0.9.3)" Main I will give you an update the next days... |
Yes, coursier is quite neat. :) I am using |
Aha! :) |
Update: Sorry, I used the wrong example. It does still not work. object Main {
def main(args: Array[String]): Unit = {
// does work :)
val f: java.util.function.Function[Int, Int] = i => i
// does not work :/
val f2: io.vavr.Function1[Int, Int] = i => i
}
} Error:
Maybe this error occurs, because Vavr's Function1 extends j.u.f.Function and scala is confused about that. 🤔 The current SNAPSHOT can be tested here: #!/bin/bash
DEPS=`coursier fetch -r https://oss.sonatype.org/content/repositories/snapshots/ -p io.vavr:vavr:0.10.0-SNAPSHOT`
scalac -d out -classpath $DEPS Main.scala
scala -classpath out:$DEPS Main |
As you said, it could be that Scala introduced a bug in recent versions regarding creation/handling of Lambda MetaFactories, MethodHandles.Lookup etc - it worked before... It would be interesting to reproduce it with a minimal non-Vavr functional interface. |
I do some further tests. TesteeI use the following testee, because it failed to compile with Vavr (see above). object Main {
def main(args: Array[String]): Unit = {
val f: test.FI[Int, Int] = i => i
}
} I compile the test the following way (using JDK8 and JDK11): javac -cp . ./test/FI.java
scalac -d out -classpath . Main.scala
scala -classpath out:. Main ✅ Extending a functional interfaceA custom Java functional interface (fi) that extends a Java standard lib fi works fine with Scala: // file FI.java
package test;
@FunctionalInterface
public interface FI<T, R> extends java.util.function.Function<T, R> {
@Override
R apply(T t);
} ✅ Internally using an auxiliary interface// file FI.java
package test;
@FunctionalInterface
public interface FI<T, R> {
static <T, R> FI<T, R> of(FI<T, R> f) {
return (FI<T, R> & Internal) f;
}
R apply(T t);
}
interface Internal {
} ✅ Internally using package private interface// file FI.java
package test;
@FunctionalInterface
public interface FI<T, R> {
static <T, R> FI<T, R> of(FI<T, R> f) {
return (FI<T, R> & Pkgprivate) f;
}
R apply(T t);
} // file Pkgprivate.java
package test;
interface Pkgprivate {
} ✅ Serializable functional interface// file FI.java
package test;
@FunctionalInterface
public interface FI<T, R> extends java.io.Serializable {
long serialVersionUID = 1L;
R apply(T t);
} |
@2m I found a minimal Java-only example and filed a Scala bug: scala/bug#11373 |
Thank you for getting to the bottom of this!
…On Sat, 19 Jan 2019, 04:45 Daniel Dietrich ***@***.*** wrote:
Closed #2337 <#2337>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2337 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAZwxgSoqOKxNkesh2Noaeg3FVUJfl9lks5vEpTSgaJpZM4Z8j3q>
.
|
When using vavr 0.9.3 with Scala 2.12.7 I am getting the following exception:
When trying to run the following code:
I compile and run the code with the following commands:
The compiled class according to javap looks like:
The text was updated successfully, but these errors were encountered: