You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/07/28 16:05:57 UTC
svn commit: r1836935 -
/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassPath.java
Author: ggregory
Date: Sat Jul 28 16:05:57 2018
New Revision: 1836935
URL: http://svn.apache.org/viewvc?rev=1836935&view=rev
Log:
[BCEL-305] ClassPath.getClassFile() and friends do not work with JRE 9 and higher. don't use a for each loop to avoid creating an iterator for the GC to collect.
Modified:
commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassPath.java
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassPath.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassPath.java?rev=1836935&r1=1836934&r2=1836935&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassPath.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/util/ClassPath.java Sat Jul 28 16:05:57 2018
@@ -407,8 +407,8 @@ public class ClassPath implements Closea
@Override
ClassFile getClassFile(final String name, final String suffix) throws IOException {
// don't use a for each loop to avoid creating an iterator for the GC to collect.
- for (final JrtModule module : modules) {
- final ClassFile classFile = module.getClassFile(name, suffix);
+ for (int i = 0; i < modules.length; i++) {
+ final ClassFile classFile = modules[i].getClassFile(name, suffix);
if (classFile != null) {
return classFile;
}
@@ -419,8 +419,8 @@ public class ClassPath implements Closea
@Override
URL getResource(final String name) {
// don't use a for each loop to avoid creating an iterator for the GC to collect.
- for (final JrtModule module : modules) {
- final URL url = module.getResource(name);
+ for (int i = 0; i < modules.length; i++) {
+ final URL url = modules[i].getResource(name);
if (url != null) {
return url;
}
@@ -431,8 +431,8 @@ public class ClassPath implements Closea
@Override
InputStream getResourceAsStream(final String name) {
// don't use a for each loop to avoid creating an iterator for the GC to collect.
- for (final JrtModule module : modules) {
- final InputStream inputStream = module.getResourceAsStream(name);
+ for (int i = 0; i < modules.length; i++) {
+ final InputStream inputStream = modules[i].getResourceAsStream(name);
if (inputStream != null) {
return inputStream;
}
@@ -489,8 +489,8 @@ public class ClassPath implements Closea
final File modulesDir = new File(modulesPath);
if (modulesDir.exists()) {
final String[] modules = modulesDir.list(MODULES_FILTER);
- for (final String module : modules) {
- list.add(modulesDir.getPath() + File.separatorChar + module);
+ for (int i = 0; i < modules.length; i++) {
+ list.add(modulesDir.getPath() + File.separatorChar + modules[i]);
}
}
}