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

Unexported classes are visible to java command

XMLWordPrintable

    • x86_64
    • linux

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


      ADDITIONAL OS VERSION INFORMATION :
      Linux xxxxxx 3.11.10-100.fc18.x86_64 #1 SMP Mon Dec 2 20:28:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Not sure if this is a bug, but seems it should be. Classes in java.base which are not exported ccan still be seen by the java execution command ('java').

      For example:

      $ java sun.security.x509.X500Name
      Error: Main method not found in class sun.security.x509.X500Name, please define the main method as:
         public static void main(String[] args)
      or a JavaFX application class must extend javafx.application.Application

      Attempting to import this class gives a correct error:

      x.java:1: error: package sun.security.x509 is not visible
      import sun.security.x509.X500Name;
                         ^
        (package sun.security.x509 is declared in module java.base, which does not export it to the unnamed module)
      1 error


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      $ java sun.security.x509.X500Name

      and observe error relating to main method not error about unexported class.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect an error relating to unexported class.
      ACTUAL -
      An error relating to missing main method is produced.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: