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

Problem handling static fields #538

Open
perNyfelt opened this issue Dec 4, 2021 · 0 comments
Open

Problem handling static fields #538

perNyfelt opened this issue Dec 4, 2021 · 0 comments

Comments

@perNyfelt
Copy link
Contributor

I am trying to create a package that allows one to to do source from a https url with a self signed certificate. It works fine from Java but when I call the java code I created, Renjin throws a java.lang.NoSuchFieldError.

I am using

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.13</version>
    </dependency>

It fails when i initialize the SSLConnectionSocketFactory with the following error:

org.renjin.eval.EvalException: INSTANCE
	at org.renjin.invoke.reflection.FunctionBinding$Overload.invoke(FunctionBinding.java:125)
	at org.renjin.invoke.reflection.FunctionBinding.invoke(FunctionBinding.java:172)
	at org.renjin.invoke.reflection.FunctionBinding.evaluateArgsAndInvoke(FunctionBinding.java:154)
	at org.renjin.invoke.reflection.MethodFunction.apply(MethodFunction.java:58)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:58)
	at org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:42)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
	at org.renjin.sexp.Closure.apply(Closure.java:133)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.sexp.ExpressionVector.eval(ExpressionVector.java:85)
	at org.renjin.eval.Context.evaluate(Context.java:280)
	at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:174)
	at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:133)
	at se.alipsa.ride.console.ConsoleComponent.executeScriptAndReport(ConsoleComponent.java:927)
	at se.alipsa.ride.console.ConsoleComponent.access$900(ConsoleComponent.java:68)
	at se.alipsa.ride.console.ConsoleComponent$3.call(ConsoleComponent.java:473)
	at se.alipsa.ride.console.ConsoleComponent$3.call(ConsoleComponent.java:468)
	at javafx.graphics/javafx.concurrent.Task$TaskCallable.call(Task.java:1425)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NoSuchFieldError: INSTANCE
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
	at se.alipsa.sourceurl.SourceUrl.fetchHttps(SourceUrl.java:74)

I initialize like this

SSLContext sslContext = SSLContexts.custom()
          .loadTrustMaterial(new TrustSelfSignedStrategy())
          .build();
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext);

The SSLConnectionSocketFactory has a field like this

    @Deprecated
    public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
        = AllowAllHostnameVerifier.INSTANCE;

...which is the reason for the failure. The AllowAllHostnameVerifier.INSTANCE looks like this:

public static final AllowAllHostnameVerifier INSTANCE = new AllowAllHostnameVerifier();

...so it is a pretty standard singleton initializer.

The package code is available here: https://github.com/perNyfelt/sourceUrl

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

No branches or pull requests

1 participant