Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8186019

module java.naming cannot access class com.sun.jndi.dns.DnsContextFactory in module jdk.naming.dns

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+166)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+166, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      II you run a Java 8 compiled program that use the DnsContextFactory it does not work anymore in Java 9.

      REGRESSION. Last worked in version 8u121

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The follow simple source code lines produce the problem:

      Hashtable<String, String> env = new Hashtable();
      env.put( "java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory" );
      DirContext dns = new InitialDirContext( env );


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      javax.naming.NoInitialContextException: Cannot instantiate class:
      com.sun.jndi.dns.DnsContextFactory [Root exception is java.lang.IllegalAccessException:
      class javax.naming.spi.NamingManager (in module java.naming) cannot access
      class com.sun.jndi.dns.DnsContextFactory (in module jdk.naming.dns) because module jdk.naming.dns
      does not export com.sun.jndi.dns to module java.naming]
          at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:719)
          at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
          at java.naming/javax.naming.InitialContext.init(InitialContext.java:236)
          at java.naming/javax.naming.InitialContext.<init>(InitialContext.java:208)
          at java.naming/javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)

      REPRODUCIBILITY :
      This bug can be reproduced always.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: