commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BCEL-304) ClassPath.getClassFile() and friends do not work with JDK 9 and higher
Date Mon, 30 Jul 2018 18:48:00 GMT

    [ https://issues.apache.org/jira/browse/BCEL-304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16562345#comment-16562345
] 

Gary Gregory commented on BCEL-304:
-----------------------------------

Nothing is scheduled ATM. If I were you I would tests the SNAPSHOT build out the wazoo on
your Java 9 or above set up and report back on the dev mailing list once you are certain that
nothing is missing or broken WRT Java >= 9.

> ClassPath.getClassFile() and friends do not work with JDK 9 and higher
> ----------------------------------------------------------------------
>
>                 Key: BCEL-304
>                 URL: https://issues.apache.org/jira/browse/BCEL-304
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 6.2
>            Reporter: Ed Pavlak
>            Assignee: Gary Gregory
>            Priority: Major
>             Fix For: 6.3
>
>
> When trying to get the class file for Java classes (ie. java.lang.String), an IOException
is thrown:
> Exception in thread "main" java.io.IOException: Couldn't find: java.lang.String.class
>  at org.apache.bcel.util.ClassPath.getClassFile(ClassPath.java:279)
>  at org.apache.bcel.util.ClassPath.getClassFile(ClassPath.java:301)
>  at bcel.test.GetClassFileTest.main(GetClassFileTest.java:12)
>  
> 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 java.io.IOException;
> 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
(v7.6.3#76005)

Mime
View raw message