Skip to content

Missing sun.security.provider.certpath when building with bazel 0.17.1 #6154

Closed

Description

@jianglai

Description of the problem / feature request:

After upgrading to v0.17.1, our code no longer builds due to the following error:

ERROR: /tmp/tmp.IHyMu87aES--dr-mkfoss/javatests/google/registry/proxy/BUILD:10:1: Building javatests/google/registry/proxy/libproxy-class.jar (29 source files) and running annotation processors (ComponentProcessor) failed (Exit 1)
javatests/google/registry/proxy/handler/SslClientInitializerTest.java:49: error: package sun.security.provider.certpath does not exist
import sun.security.provider.certpath.SunCertPathBuilderException;
                                     ^

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ git clone https://github.com/google/nomulus.git && cd nomulus
$ bazel build //javatests/google/registry/proxy
Starting local Bazel server and connecting to it...
INFO: SHA256 (https://github.com/bazelbuild/rules_docker/archive/v0.4.0.tar.gz) = 6dede2c65ce86289969b907f343a1382d33c14fbce5e30dd17bb59bb55bb6593
INFO: Analysed target //javatests/google/registry/proxy:proxy (137 packages loaded).
INFO: Found 1 target...
INFO: From Building external/com_google_protobuf/libprotobuf_java.jar (77 source files, 1 source jar) [for host]:
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
INFO: From Building external/com_google_protobuf/libprotobuf_java.jar (77 source files, 1 source jar):
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
INFO: From Generating SOY v2 Java files //java/google/registry/flows:soy_java_wrappers_files:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/local/google/home/jianglai/.cache/bazel/_bazel_jianglai/07a62f1737d31e5e75c35ed0215c5b46/external/com_google_inject_guice/guice-4.1.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
ERROR: /usr/local/google/home/jianglai/Downloads/nomulus/javatests/google/registry/proxy/BUILD:10:1: Building javatests/google/registry/proxy/libproxy-class.jar (29 source files) and running annotation processors (ComponentProcessor) failed (Exit 1)
javatests/google/registry/proxy/handler/SslClientInitializerTest.java:49: error: package sun.security.provider.certpath does not exist
import sun.security.provider.certpath.SunCertPathBuilderException;
                                     ^
Target //javatests/google/registry/proxy:proxy failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 92.856s, Critical Path: 66.19s
INFO: 327 processes: 302 linux-sandbox, 25 worker.
FAILED: Build did NOT complete successfully

What operating system are you running Bazel on?

$ uname -a
Linux jianglai.nyc.corp.google.com 4.17.0-3rodete2-amd64 #1 SMP Debian 4.17.17-1rodete2 (2018-08-28) x86_64 GNU/Linux

What's the output of bazel info release?

$ bazel info release
release 0.17.1

Any other information, logs, or outputs that you want to share?

I think this has to do project jigsaw? Is sun.security.provider.certpath no longer provided in the default root module? Is there a known solution?

Thanks.

Activity

  1. cushon commented on Sep 14, 2018

    @cushon
    Contributor

    I think this has to do project jigsaw? Is sun.security.provider.certpath no longer provided in the default root module?

    I think that's accurate:

    $ cat T.java 
    class T {
      sun.security.provider.certpath.SunCertPathBuilderException x;
    }
    $ javac -version
    javac 11
    $ javac T.java
    T.java:2: error: package sun.security.provider.certpath is not visible
      sun.security.provider.certpath.SunCertPathBuilderException x;
                           ^
      (package sun.security.provider.certpath is declared in module java.base, which does not export it to the unnamed module)
    $ javac --release 8 T.java
    T.java:2: error: package sun.security.provider.certpath does not exist
      sun.security.provider.certpath.SunCertPathBuilderException x;
                                    ^
    

    This is related to JDK-8206937.

  2. added
    team-Rules-Java
    on Sep 14, 2018
  3. jianglai commented on Sep 14, 2018

    @jianglai
    Author

    Any temporary workaround?

  4. cushon commented on Sep 14, 2018

    @cushon
    Contributor

    That test is the only use of sun.security.provider.certpath.SunCertPathBuilderException. Do you care if the exception is the sun.security type, or could you test for java.security.cert.CertPathBuilderException instead?

    diff --git a/javatests/google/registry/proxy/handler/SslClientInitializerTest.java b/javatests/google/registry/proxy/handler/SslClientInitializerTest.java
    index 34b2b720..c6232d84 100644
    --- a/javatests/google/registry/proxy/handler/SslClientInitializerTest.java
    +++ b/javatests/google/registry/proxy/handler/SslClientInitializerTest.java
    @@ -37,6 +37,7 @@ import io.netty.handler.ssl.SslProvider;
     import io.netty.handler.ssl.util.SelfSignedCertificate;
     import java.security.KeyPair;
     import java.security.PrivateKey;
    +import java.security.cert.CertPathBuilderException;
     import java.security.cert.CertificateException;
     import java.security.cert.X509Certificate;
     import javax.net.ssl.SSLException;
    @@ -46,7 +47,6 @@ import org.junit.runner.RunWith;
     import org.junit.runners.Parameterized;
     import org.junit.runners.Parameterized.Parameter;
     import org.junit.runners.Parameterized.Parameters;
    -import sun.security.provider.certpath.SunCertPathBuilderException;
     
     /**
      * Unit tests for {@link SslClientInitializer}.
    @@ -142,7 +142,7 @@ public class SslClientInitializerTest {
         nettyRule.setUpClient(localAddress, PROTOCOL, sslClientInitializer);
         // The connection is now terminated, both the client side and the server side should get
         // exceptions.
    -    nettyRule.assertThatClientRootCause().isInstanceOf(SunCertPathBuilderException.class);
    +    nettyRule.assertThatClientRootCause().isInstanceOf(CertPathBuilderException.class);
         nettyRule.assertThatServerRootCause().isInstanceOf(SSLException.class);
         assertThat(nettyRule.getChannel().isActive()).isFalse();
       }
  5. cushon commented on Sep 14, 2018

    @cushon
    Contributor
  6. jianglai commented on Sep 15, 2018

    @jianglai
    Author

    Thanks, it worked!

  7. cushon commented on Sep 15, 2018

    @cushon
    Contributor

    Thanks for confirming! I'll leave this bug open to track the underlying problem.

  8. cushon commented on Sep 18, 2018

    @cushon
    Contributor

    I started #6179 to track the underlying problem.

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

Metadata

Metadata

Assignees

Labels

team-Rules-Java

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions