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

Wildcard expansion for single entry classpath

    Details

    • Subcomponent:
    • Introduced In Build:
      b108
    • Introduced In Version:
      7
    • Resolved In Build:
      b52
    • CPU:
      generic, x86
    • OS:
      windows, windows_xp, windows_2008, windows_7
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0_03"
        Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
        Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        Wildcard expansion doesn't work correctly for -classpath (-cp) parameter when only one entry is specified.


        REGRESSION. Last worked in version 6u29

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Script (batch file) for running the test:

        mkdir lib
        javac test/*.java
        jar cvf lib/a.jar test/A.class
        jar cvf lib/b.jar test/B.class
        java -cp "lib/*" test.B


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Following message should be on the output:

        main() in class B executed

        ACTUAL -
        Following message appears on the output:

        Error: Could not find or load main class lib.b.jar

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Java launcher debug info when it doesn't work:

        ----_JAVA_LAUNCHER_DEBUG----
        Launcher state:
                debug:on
                javargs:off
                program name:java
                launcher name:java
                javaw:off
                fullversion:1.7.0_03-b05
                dotversion:1.7
                ergo_policy:DEFAULT_ERGONOMICS_POLICY
        Command line args:
        argv[0] = java
        argv[1] = -cp
        argv[2] = lib/a.jar
        argv[3] = lib/b.jar
        argv[4] = test.B
        JRE path is c:\Program Files\Java\jre7
        jvm.cfg[0] = ->-client<-
        jvm.cfg[1] = ->-server<-
        jvm.cfg[2] = ->-hotspot<-
            name: -hotspot vmType: VM_ALIASED_TO alias: -client
        jvm.cfg[3] = ->-classic<-
        jvm.cfg[4] = ->-native<-
        jvm.cfg[5] = ->-green<-
        8371 micro seconds to parse jvm.cfg
        Default VM: client
        JVM path is c:\Program Files\Java\jre7\bin\client\jvm.dll
        JRE path is c:\Program Files\Java\jre7
        CRT path is c:\Program Files\Java\jre7\bin\msvcr100.dll
        8795 micro seconds to LoadJavaVM
        JavaVM args:
            version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 5
            option[ 0] = '-Dsun.java.launcher.diag=true'
            option[ 1] = '-Djava.class.path=.'
            option[ 2] = '-Djava.class.path=lib/a.jar'
            option[ 3] = '-Dsun.java.command=lib/b.jar test.B'
            option[ 4] = '-Dsun.java.launcher=SUN_STANDARD'
        59450 micro seconds to InitializeJVM
        Main class is 'lib/b.jar'
        App's argc is 1
            argv[ 0] = 'test.B'
        Error: Could not find or load main class lib.b.jar
        java.lang.ClassNotFoundException: lib.b.jar
                at java.net.URLClassLoader$1.run(Unknown Source)
                at java.net.URLClassLoader$1.run(Unknown Source)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.net.URLClassLoader.findClass(Unknown Source)
                at java.lang.ClassLoader.loadClass(Unknown Source)
                at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
                at java.lang.ClassLoader.loadClass(Unknown Source)
                at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)


        Java launcher debug info when it works:

        ----_JAVA_LAUNCHER_DEBUG----
        Launcher state:
        debug:on
        javargs:off
        program name:java
        launcher name:java
        javaw:off
        fullversion:1.7.0_03-b05
        dotversion:1.7
        ergo_policy:DEFAULT_ERGONOMICS_POLICY
        Command line args:
        argv[0] = java
        argv[1] = -cp
        argv[2] = lib/*;
        argv[3] = test.B
        JRE path is c:\Program Files\Java\jre7
        jvm.cfg[0] = ->-client<-
        jvm.cfg[1] = ->-server<-
        jvm.cfg[2] = ->-hotspot<-
            name: -hotspot vmType: VM_ALIASED_TO alias: -client
        jvm.cfg[3] = ->-classic<-
        jvm.cfg[4] = ->-native<-
        jvm.cfg[5] = ->-green<-
        322 micro seconds to parse jvm.cfg
        Default VM: client
        JVM path is c:\Program Files\Java\jre7\bin\client\jvm.dll
        JRE path is c:\Program Files\Java\jre7
        CRT path is c:\Program Files\Java\jre7\bin\msvcr100.dll
        5365 micro seconds to LoadJavaVM
        Expanded wildcards:
            before: "lib/*;"
            after : "lib/a.jar;lib/b.jar;"
        JavaVM args:
            version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 5
            option[ 0] = '-Dsun.java.launcher.diag=true'
            option[ 1] = '-Djava.class.path=.'
            option[ 2] = '-Djava.class.path=lib/a.jar;lib/b.jar;'
            option[ 3] = '-Dsun.java.command=test.B'
            option[ 4] = '-Dsun.java.launcher=SUN_STANDARD'
        51245 micro seconds to InitializeJVM
        Main class is 'test.B'
        App's argc is 0
        13358 micro seconds to load main class
        ----_JAVA_LAUNCHER_DEBUG----



        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        File test/A.java:
        ---
        package test;

        class A {
        }
        ---

        File test/B.java:
        ---
        package test;

        class B {
            public static void main(String[] args) {
                System.out.println("main() in class B executed");
            }
        }
        ---

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Command line for executing the code must be modified e.g. like following:

        java -cp "lib/*;" test.B

        Please note that instead of "*" is there "*;". Then execution works as expected.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ksrini Kumar Srinivasan
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: