Skip to content

Commit

Permalink
fixed bug in jar converter w.r.t. reading single class file (an NPE) …
Browse files Browse the repository at this point in the history
…and a classpath parameter was missing for looking up parent classes in the hierarchy
  • Loading branch information
jurgenvinju committed Jan 25, 2024
1 parent 91e71a5 commit e3976ab
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/org/rascalmpl/library/TestMe.rsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module TestMe

import IO;
import util::Benchmark;
import util::Math;

void main() {
results = for (i <- [2,3,4,5]) {
println("2^<i> chains");
append cpuTimeOf(() {
R = {<j, j+1> | j <- [0..toInt(pow(10,i))], j % 100 != 0};
R+;
});
}

iprintln(results);
}
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/lang/java/m3/Core.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ java M3 createM3FromString(loc fileName, str contents, bool errorRecovery = fals
java M3 createM3FromJarClass(loc jarClass, list[loc] classPath = []);
@javaClass{org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler}
java M3 createM3FromSingleClass(loc jarClass, str className);
java M3 createM3FromSingleClass(loc jarClass, str className, list[loc] classPath = []);
@javaClass{org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler}
java M3 createM3FromJarFile(loc jarLoc, list[loc] classPath = []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public IValue createM3FromJarClass(ISourceLocation jarLoc, IList classPath) {
return createM3FromJarClass(jarLoc, classPath, getM3Store());
}

public IValue createM3FromSingleClass(ISourceLocation classLoc, IString className) {
public IValue createM3FromSingleClass(ISourceLocation classLoc, IString className, IList classpath) {
JarConverter converter = new JarConverter(getM3Store(), new HashMap<>());
converter.convertJarFile(classLoc, ((IString) className).getValue());
converter.convertJarFile(classLoc, ((IString) className).getValue(), classpath);
return converter.getModel(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public void convertJar(ISourceLocation jar, IList classPath) {
* @param classFile
* @param className
*/
public void convertJarFile(ISourceLocation classFile, String className) {
public void convertJarFile(ISourceLocation classFile, String className, IList classpath) {
loc = classFile;
createSingleClassM3(className);
createSingleClassM3(className, classpath);
}

/**
Expand Down Expand Up @@ -172,7 +172,11 @@ private void createM3() {
* and parent packages is triggered.
* @param className
*/
private void createSingleClassM3(String className) {
private void createSingleClassM3(String className, IList classpath) {
if (resolver == null) {
resolver = new ASMNodeResolver(loc, classpath, typeStore);
}

String compUnit = className;
ClassReader classReader = resolver.buildClassReader(className);

Expand Down

0 comments on commit e3976ab

Please sign in to comment.