Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
pron committed Jul 17, 2014
1 parent f692cff commit 4edddd2
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 135 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -322,7 +322,7 @@ project (':quasar-core') {
name:'autoScanSuspendables', classname:'co.paralleluniverse.fibers.instrument.AutoSuspendablesScanner$AntTask',
classpath: configurations.compile.asPath + ":${jar.archivePath}:build/classes/test")
ant.autoScanSuspendables(
outputSuspenableFile:"$sourceSets.test.output.resourcesDir/META-INF/testSuspendables",
outputSuspendableFile:"$sourceSets.test.output.resourcesDir/META-INF/testSuspendables",
outputSupersFile:"$sourceSets.test.output.resourcesDir/META-INF/testSuspendableSupers" )
}
}
Expand Down
Expand Up @@ -55,6 +55,11 @@ public final class ClassLoaderUtil {
public interface Visitor {
void visit(String resource, URL url, ClassLoader cl);
}

public enum ScanMode {
WHOLE_CLASSPATH, WITHOUT_JARS
}

private static final Splitter CLASS_PATH_ATTRIBUTE_SEPARATOR = Splitter.on(" ").omitEmptyStrings();
private static final String CLASS_FILE_NAME_EXTENSION = ".class";

Expand All @@ -79,9 +84,13 @@ public static String classToSlashed(Class<?> clazz) {
}

public static String resourceToClass(String resourceName) {
return resourceToSlashed(resourceName).replace('/', '.');
}

public static String resourceToSlashed(String resourceName) {
if (!resourceName.endsWith(CLASS_FILE_NAME_EXTENSION))
throw new IllegalArgumentException("Resource " + resourceName + " is not a class file");
return resourceName.substring(0, resourceName.length() - CLASS_FILE_NAME_EXTENSION.length()).replace('/', '.');
return resourceName.substring(0, resourceName.length() - CLASS_FILE_NAME_EXTENSION.length());
}

public static void accept(URLClassLoader ucl, Visitor visitor) throws IOException {
Expand All @@ -90,7 +99,6 @@ public static void accept(URLClassLoader ucl, Visitor visitor) throws IOExceptio

public static void accept(URLClassLoader ucl, ScanMode scanMode, Visitor visitor) throws IOException {
accept(ucl, ucl.getURLs(), scanMode, visitor);

}

public static void accept(ClassLoader cl, URL[] urls, ScanMode scanMode, Visitor visitor) throws IOException {
Expand Down Expand Up @@ -223,8 +231,4 @@ private static URI getClassPathEntry(File jarFile, String path) throws URISyntax

private ClassLoaderUtil() {
}

public enum ScanMode {
WHOLE_CLASSPATH, WITHOUT_JARS
}
}

0 comments on commit 4edddd2

Please sign in to comment.