I'm using Scala with a Java library that expects to be passed a class with a public static void main(java.lang.String[])
so it can run call it via reflection for integration tests.
object RestServer {
def main(args: Array[String]): Unit = { /* run the server */ }
}
Due to the behavior described in this answer to another question, this gets compiled to two classes.
public final class com.example.RestServer$ {
public static final com.optum.cql.rest.RestServer$ MODULE$;
public static {};
public void main(java.lang.String[]);
}
and
public final class com.example.RestServer {
public static void main(java.lang.String[]);
}
When I pass the class to the library
@IntegrationTest(main = classOf[RestServer.type])
class MyTests extends RapidoidIntegrationTest { }
I'm actually passing the object
singleton instance (RestServer$
), not the RestServer
class that has the static void main()
method.
This wouldn't be a problem, except the library verifies that the method it is calling is both public
and static
before calling it?
How can I get the RestServer
class instead?
Aucun commentaire:
Enregistrer un commentaire