Skip to content

Commit

Permalink
Update JarClassFileContainer to comply with new class URI structure
Browse files Browse the repository at this point in the history
This is related to the issue javapathfinder#50 which is about JPF failing to load
model classes from jpf-classes.jar due to different URI structure of the
.class files being introuduced in Java Module System.

The previous workaround introudced by the PR javapathfinder#51 is specifically for the
jpf-classes.jar And JPF will still fail to locate classes from the other
jar files.

Thus this reverts it. And make a implementation changes to
JarClassFileContainer which is JPF's universal continer for loading
classes from any jar file.
  • Loading branch information
gayanW committed Jun 25, 2018
1 parent 51ed8ac commit 5b688be
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/gov/nasa/jpf/jvm/JarClassFileContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ static String getPath(File file, String pathPrefix){
}

@Override
public ClassFileMatch getMatch(String clsName) throws ClassParseException {
String pn = clsName.replace('.', '/') + ".class";
public ClassFileMatch getMatch(String clsName) throws ClassParseException, ClassNotFoundException {
String moduleName = Class.forName(clsName).getModule().getName();
String entryName = moduleName + "/" + clsName.replace('.', '/') + ".class";

if (pathPrefix != null){
pn = pathPrefix + pn;
entryName = pathPrefix + entryName;
}

JarEntry e = jar.getJarEntry(pn);
JarEntry e = jar.getJarEntry(entryName);

if (e != null) {
InputStream is = null;
Expand Down

0 comments on commit 5b688be

Please sign in to comment.