commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (BCEL-304) ClassPath.getClassFile does not work with Java 9 and higher
Date Fri, 27 Jul 2018 20:03:00 GMT


ASF GitHub Bot commented on BCEL-304:

GitHub user epavlak opened a pull request:

    [BCEL-304] Include Java 9+ modules in path used by

    With the restructuring of Java .class files in Java 9 and higher to be in modules instead
of the rt.jar, the ClassPath.getClassFile method would fail to find Java class files (ex:
String.class). These modifications include the Java 9+ modules in the path used by
so that the .class files can be located.

You can merge this pull request into a Git repository by running:

    $ git pull BCEL-304

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22
commit e331171f168ab335b9756294406e85d9995731bd
Author: epavlak <epavlak@...>
Date:   2018-07-27T19:50:30Z

    [BCEL-304] Include Java 9+ modules in path used by

commit 98157fb61a547d8d4fe40826d1f863a1c1f1c374
Author: epavlak <epavlak@...>
Date:   2018-07-27T19:53:58Z

    [BCEL-304] Include Java 9+ modules in path used by

commit d5a73b6987eb262d90f809e3a2b77845fcce95d2
Author: epavlak <epavlak@...>
Date:   2018-07-27T19:56:57Z

    [BCEL-304] Include Java 9+ modules in path used by


> ClassPath.getClassFile does not work with Java 9 and higher
> -----------------------------------------------------------
>                 Key: BCEL-304
>                 URL:
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 6.2
>            Reporter: Ed Pavlak
>            Priority: Major
> When trying to get the class file for Java classes (ie. java.lang.String), an IOException
is thrown:
> Exception in thread "main" Couldn't find: java.lang.String.class
>  at org.apache.bcel.util.ClassPath.getClassFile(
>  at org.apache.bcel.util.ClassPath.getClassFile(
>  at bcel.test.GetClassFileTest.main(
> The root cause appears to be the restructuring of Java starting with Java 9. Specifically,
the removal of the rt.jar. The above excpetion can be reproduced using a simple application:
> package bcel.test;
> import;
> import org.apache.bcel.util.ClassPath;
> public class GetClassFileTest {
>    public static void main(String[] args) throws IOException {
>       String className = "java.lang.String";
>       System.out.println("Looking up ClassPath.ClassFile for: " + className);
>       ClassPath.ClassFile classFile = ClassPath.SYSTEM_CLASS_PATH.getClassFile(className);
>       if (classFile != null) {
>          System.out.println("Class file base: " + classFile.getBase());
>          System.out.println("Class file path: " + classFile.getPath());
>       }
>    }
> }
> Running this on Java 8 produces the following output, whereas running it on Java 9+ produces
the IOException:
> Class file base: C:\jdk1.8.0_161\jre\lib\rt.jar
> Class file path: java/lang/String.class

This message was sent by Atlassian JIRA

View raw message