-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
GraalVM native shared library for scala #5551
Comments
Thank you for your report, tracked internally on GR 42873 |
if you're using scala 3 then probably adding import com.google.common.math.IntMath
import org.graalvm.nativeimage.IsolateThread
import org.graalvm.nativeimage.c.function.CEntryPoint
import scala.annotation.static
class MyMath {
override def toString = "Hello"
}
object MyMath {
@static // i'm not sure if it's needed here
var count = 0
@CEntryPoint(name = "ceilingPowerOfTwoScala")
@static
def ceilingPowerOfTwoScala(thread: IsolateThread, x: Int): Int = {
count = IntMath.ceilingPowerOfTwo(x)
count
}
@CEntryPoint(name = "incrementFunctionScala")
@static
def incrementFunctionScala(thread: IsolateThread): Int = IntMath.checkedAdd(count, 1)
} simpler example: https://scastie.scala-lang.org/Wj7SuiilQRuXsKgmxXQlAA |
Yes, It works in scala 3 but my codebase in scala 2 |
it seems that the problem is more with scala 2 than with native-image. as a workaround, you can mix java and scala code, e.g. define an entrypoint in java that calls methods on scala singleton objects. theoretically, graalvm native-image could do that workaround automatically, but then it would need to be able to recognize singletons and treat their methods somewhat like static ones. |
Feature request
Please include the following information:
I'm looking for a Native Shared Library and I want to achieve with scala
Is your feature request related to a problem? Please describe.
Error: Entry point method MyMath$.incrementFunctionScala is not static. Add a static modifier to the method.
On another hand, without that example, I get the below section of output and there is no .h header file for my object
Describe who do you think will benefit the most.
to reach scala environment
The text was updated successfully, but these errors were encountered: