Reports for loops which iterate over collections or arrays, and can be replaced with an enhanced for loop (i.e. the foreach iteration syntax). Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>tags/V1_9_7M1
@@ -183,9 +183,9 @@ public class BrowserManager { | |||
private List<String> getConfigFilesList(String[] configFiles) { | |||
List<String> configs = new ArrayList<String>(); | |||
for (int i = 0; i < configFiles.length; i++) { | |||
if (configFiles[i].endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { | |||
configs.add(configFiles[i]); | |||
for (String configFile : configFiles) { | |||
if (configFile.endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { | |||
configs.add(configFile); | |||
} | |||
} | |||
return configs; |
@@ -42,8 +42,8 @@ public class Main { | |||
return false; | |||
} | |||
int numConfigFiles = 0; | |||
for (int i = 0; i < args.length; i++) { | |||
if ((null != args[i]) && args[i].endsWith(".lst")) { | |||
for (String arg : args) { | |||
if ((null != arg) && arg.endsWith(".lst")) { | |||
numConfigFiles++; | |||
} | |||
} |
@@ -43,8 +43,7 @@ public class BrowserCompilerConfiguration implements ICompilerConfiguration { | |||
classpath.append(userPath); | |||
} | |||
List<File> outputDirs = getOutputLocationManager().getAllOutputLocations(); | |||
for (Iterator<File> iterator = outputDirs.iterator(); iterator.hasNext();) { | |||
File dir = (File) iterator.next(); | |||
for (File dir : outputDirs) { | |||
classpath.append(File.pathSeparator + dir.getAbsolutePath() + File.pathSeparator); | |||
} | |||
classpath.append(System.getProperty("java.class.path", ".")); |
@@ -73,8 +73,8 @@ public class MessageHandlerPanel extends JPanel { | |||
private void createList(List<IMessage> messages) { | |||
list = new JList(); | |||
listModel = new DefaultListModel(); | |||
for (Iterator<IMessage> iterator = messages.iterator(); iterator.hasNext();) { | |||
listModel.addElement(iterator.next()); | |||
for (IMessage message : messages) { | |||
listModel.addElement(message); | |||
} | |||
} | |||
@@ -250,11 +250,11 @@ public class AjdeCoreBuildManager { | |||
args = new String[l.size() + xmlfiles.size() + 1]; | |||
// TODO speedup | |||
int p = 0; | |||
for (int i = 0; i < l.size(); i++) { | |||
args[p++] = l.get(i); | |||
for (String s : l) { | |||
args[p++] = s; | |||
} | |||
for (int i = 0; i < xmlfiles.size(); i++) { | |||
args[p++] = xmlfiles.get(i); | |||
for (String xmlfile : xmlfiles) { | |||
args[p++] = xmlfile; | |||
} | |||
args[p++] = "-xmlConfigured"; | |||
} else { |
@@ -85,8 +85,7 @@ public abstract class AjdeCoreTestCase extends TestCase { | |||
String contents[] = from.list(); | |||
if (contents == null) | |||
return; | |||
for (int i = 0; i < contents.length; i++) { | |||
String string = contents[i]; | |||
for (String string : contents) { | |||
File f = new File(from, string); | |||
File t = new File(to, string); | |||
@@ -141,8 +140,8 @@ public abstract class AjdeCoreTestCase extends TestCase { | |||
public List<String> getSourceFileList(String[] files) { | |||
List<String> sourceFiles = new ArrayList<String>(); | |||
for (int i = 0; i < files.length; i++) { | |||
sourceFiles.add(getAbsoluteProjectDir() + File.separator + files[i]); | |||
for (String file : files) { | |||
sourceFiles.add(getAbsoluteProjectDir() + File.separator + file); | |||
} | |||
return sourceFiles; | |||
} |
@@ -116,17 +116,17 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { | |||
/* Allow the user to override the testProjectPath by using sourceRoots */ | |||
File[] srcBase = new File[] { new File(projectPath + File.separator + srcDirName) }; | |||
for (int j = 0; j < srcBase.length; j++) { | |||
File[] fromResources = FileUtil.listFiles(srcBase[j], new FileFilter() { | |||
for (File file : srcBase) { | |||
File[] fromResources = FileUtil.listFiles(file, new FileFilter() { | |||
public boolean accept(File pathname) { | |||
String name = pathname.getName().toLowerCase(); | |||
return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj") | |||
&& !name.endsWith(".lst") && !name.endsWith(".jar"); | |||
} | |||
}); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
String normPath = FileUtil.normalizedPath(fromResources[i], srcBase[j]); | |||
sourcePathResources.put(normPath, fromResources[i]); | |||
for (File fromResource : fromResources) { | |||
String normPath = FileUtil.normalizedPath(fromResource, file); | |||
sourcePathResources.put(normPath, fromResource); | |||
} | |||
} |
@@ -135,8 +135,7 @@ public class AjConfigTest extends AjdeCoreTestCase { | |||
compilerConfig.setSourcePathResources(m); | |||
AjBuildConfig buildConfig = genAjBuildConfig(); | |||
Map<String, File> found = buildConfig.getSourcePathResources(); | |||
for (Iterator<String> i = found.keySet().iterator(); i.hasNext();) { | |||
String resource = i.next(); | |||
for (String resource : found.keySet()) { | |||
assertEquals("expected to find resource with name newFile.txt but " + "found " + resource, "newFile.txt", resource); | |||
File from = buildConfig.getSourcePathResources().get(resource); | |||
assertEquals("expected to find resource with file " + getWorkingDir() + "but found " + from, getWorkingDir(), from); |
@@ -294,8 +294,7 @@ public class InpathTest extends AjdeCoreTestCase { | |||
File binBase = openFile(outdirName); | |||
String[] toResources = FileUtil.listFiles(binBase); | |||
for (int i = 0; i < toResources.length; i++) { | |||
String fileName = toResources[i]; | |||
for (String fileName : toResources) { | |||
if (fileName.indexOf("CVS") == -1) { | |||
boolean b = expectedOutdirContents.remove(fileName); | |||
assertTrue("Extraneous resources: " + fileName, b); | |||
@@ -308,8 +307,8 @@ public class InpathTest extends AjdeCoreTestCase { | |||
private void listSourceResources(String indirName, Set<String> resources) { | |||
File srcBase = openFile(indirName); | |||
File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
String name = FileUtil.normalizedPath(fromResources[i], srcBase); | |||
for (File fromResource : fromResources) { | |||
String name = FileUtil.normalizedPath(fromResource, srcBase); | |||
// System.err.println("Checking "+name); | |||
if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { | |||
resources.add(name); |
@@ -155,8 +155,8 @@ public class ResourceCopyTest extends AjdeCoreTestCase { | |||
HashSet<String> resources = new HashSet<>(); | |||
listSourceResources(indirName, resources); | |||
for (int i = 0; i < toResources.length; i++) { | |||
String fileName = FileUtil.normalizedPath(toResources[i], binBase); | |||
for (File toResource : toResources) { | |||
String fileName = FileUtil.normalizedPath(toResource, binBase); | |||
boolean b = resources.remove(fileName); | |||
assertTrue("Extraneous resources: " + fileName, b); | |||
} | |||
@@ -167,8 +167,8 @@ public class ResourceCopyTest extends AjdeCoreTestCase { | |||
private void listSourceResources(String indirName, Set<String> resources) { | |||
File srcBase = openFile(indirName); | |||
File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
String name = FileUtil.normalizedPath(fromResources[i], srcBase); | |||
for (File fromResource : fromResources) { | |||
String name = FileUtil.normalizedPath(fromResource, srcBase); | |||
if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { | |||
resources.add(name); | |||
} | |||
@@ -263,12 +263,12 @@ public class ResourceCopyTest extends AjdeCoreTestCase { | |||
File binBase = openFile(outdirName); | |||
File[] toResources = FileUtil.listFiles(binBase, aspectjResourceFileFilter); | |||
for (int i = 0; i < toResources.length; i++) { | |||
String fileName = FileUtil.normalizedPath(toResources[i], binBase); | |||
for (File toResource : toResources) { | |||
String fileName = FileUtil.normalizedPath(toResource, binBase); | |||
/* Ensure we copied the right JAR manifest */ | |||
if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) { | |||
byte[] outManifest = FileUtil.readAsByteArray(toResources[i]); | |||
byte[] outManifest = FileUtil.readAsByteArray(toResource); | |||
assertTrue("Wrong manifest has been copied", Arrays.equals(inManifest, outManifest)); | |||
} | |||
boolean b = resources.remove(fileName); |
@@ -376,8 +376,8 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { | |||
// See if the messages match | |||
int msgCount = 0; | |||
List<TestMessageHandler.TestMessage> l = handler.getMessages(); | |||
for (Iterator<TestMessageHandler.TestMessage> iter = l.iterator(); iter.hasNext();) { | |||
IMessage msg = iter.next().getContainedMessage(); | |||
for (TestMessageHandler.TestMessage testMessage : l) { | |||
IMessage msg = testMessage.getContainedMessage(); | |||
if (debugTests) | |||
System.out.println("Looking at [" + msg + "]"); | |||
if (msg.getKind().equals(IMessage.WEAVEINFO)) { | |||
@@ -416,8 +416,8 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { | |||
try { | |||
fw = new FileWriter(f); | |||
List<TestMessageHandler.TestMessage> l = handler.getMessages(); | |||
for (Iterator<TestMessageHandler.TestMessage> iter = l.iterator(); iter.hasNext();) { | |||
IMessage msg = iter.next().getContainedMessage(); | |||
for (TestMessageHandler.TestMessage testMessage : l) { | |||
IMessage msg = testMessage.getContainedMessage(); | |||
if (msg.getKind().equals(IMessage.WEAVEINFO)) { | |||
fw.write(msg.getMessage() + "\n"); | |||
} |
@@ -139,8 +139,7 @@ public class AsmRelationshipsTest extends AjdeCoreTestCase { | |||
.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec); | |||
assertNotNull(beforeExecNode); | |||
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName); | |||
for (Iterator<String> it = rel.getTargets().iterator(); it.hasNext();) { | |||
String currHandle = it.next(); | |||
for (String currHandle : rel.getTargets()) { | |||
if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(to)) | |||
return; | |||
} | |||
@@ -186,8 +185,7 @@ public class AsmRelationshipsTest extends AjdeCoreTestCase { | |||
// String set = to; | |||
IRelationship rel2 = manager.getRelationshipMap().get(clazz, IRelationship.Kind.DECLARE_INTER_TYPE, backRelName); | |||
// String handle2 = (String)rel2.getTargets().get(0); | |||
for (Iterator<String> it = rel2.getTargets().iterator(); it.hasNext();) { | |||
String currHandle = it.next(); | |||
for (String currHandle : rel2.getTargets()) { | |||
if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(from)) | |||
return; | |||
} |
@@ -116,8 +116,7 @@ public class StructureModelTest extends AjdeCoreTestCase { | |||
} | |||
private void testModelIntegrityHelper(IProgramElement node) throws Exception { | |||
for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) { | |||
IProgramElement child = (IProgramElement) it.next(); | |||
for (IProgramElement child : node.getChildren()) { | |||
if (node == child.getParent()) { | |||
testModelIntegrityHelper(child); | |||
} else { | |||
@@ -131,8 +130,8 @@ public class StructureModelTest extends AjdeCoreTestCase { | |||
public void preProcess(IProgramElement node) { | |||
if (node.getChildren() == null) | |||
return; | |||
for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) { | |||
if (it.next() == null) | |||
for (IProgramElement iProgramElement : node.getChildren()) { | |||
if (iProgramElement == null) | |||
throw new NullPointerException("null child on node: " + node.getName()); | |||
} | |||
} |
@@ -262,8 +262,8 @@ public class Ajde { | |||
} else { | |||
StringBuffer sb = new StringBuffer(); | |||
List outputDirs = compilerConfig.getOutputLocationManager().getAllOutputLocations(); | |||
for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) { | |||
File dir = (File) iterator.next(); | |||
for (Object outputDir : outputDirs) { | |||
File dir = (File) outputDir; | |||
sb.append(dir.getAbsolutePath() + File.pathSeparator); | |||
} | |||
classpath = LangUtil.makeClasspath(null, compilerConfig.getClasspath(), sb.toString(), compilerConfig.getOutJar()); |
@@ -56,20 +56,20 @@ class LstBuildConfigFileUpdater { | |||
* Adds an entry to multiple build configuration files. | |||
*/ | |||
public void updateBuildConfigFiles(List buildConfigFiles, List<String> filesToUpdate, boolean addToConfiguration) { | |||
for (int i = 0; i < buildConfigFiles.size(); i++) { | |||
List<String> fileContents = readConfigFile((String) buildConfigFiles.get(i)); | |||
for (Object buildConfigFile : buildConfigFiles) { | |||
List<String> fileContents = readConfigFile((String) buildConfigFile); | |||
if (addToConfiguration) { | |||
for (int j = 0; j < filesToUpdate.size(); j++) { | |||
fileContents.add(filesToUpdate.get(j)); | |||
for (String s : filesToUpdate) { | |||
fileContents.add(s); | |||
} | |||
} else { | |||
for (int k = 0; k < filesToUpdate.size(); k++) { | |||
if (fileContents.contains(filesToUpdate.get(k))) { | |||
fileContents.remove(filesToUpdate.get(k)); | |||
for (String s : filesToUpdate) { | |||
if (fileContents.contains(s)) { | |||
fileContents.remove(s); | |||
} | |||
} | |||
} | |||
writeConfigFile((String) buildConfigFiles.get(i), fileContents); | |||
writeConfigFile((String) buildConfigFile, fileContents); | |||
} | |||
} | |||
@@ -122,16 +122,14 @@ class LstBuildConfigFileUpdater { | |||
String fileContentsString = ""; | |||
// List filesToWrite = null; | |||
Set<String> includedFiles = new HashSet<>(); | |||
for (Iterator<BuildConfigNode> it = importedNodes.iterator(); it.hasNext();) { | |||
BuildConfigNode node = it.next(); | |||
for (BuildConfigNode node : importedNodes) { | |||
fileContentsString += '@' + node.getResourcePath() + "\n"; | |||
String parentPath = new File(filePath).getParent(); | |||
String importedFilePath = parentPath + File.separator + node.getResourcePath(); | |||
includedFiles.addAll(getIncludedFiles(importedFilePath, parentPath)); | |||
} | |||
for (Iterator<BuildConfigNode> it = files.iterator(); it.hasNext();) { | |||
BuildConfigNode node = it.next(); | |||
for (BuildConfigNode node : files) { | |||
if (node.getName().endsWith(".lst") && !node.getResourcePath().startsWith("..")) { | |||
fileContentsString += '@'; | |||
fileContentsString += node.getResourcePath() + "\n"; | |||
@@ -150,8 +148,8 @@ class LstBuildConfigFileUpdater { | |||
configParser.parseConfigFile(new File(path)); | |||
List<File> files = configParser.getFiles(); | |||
List<String> relativeFiles = new ArrayList<String>(); | |||
for (Iterator<File> it = files.iterator(); it.hasNext();) { | |||
relativeFiles.add(relativizePath(it.next().getPath(), rootPath)); | |||
for (File file : files) { | |||
relativeFiles.add(relativizePath(file.getPath(), rootPath)); | |||
} | |||
return relativeFiles; | |||
} catch (ConfigParser.ParseException pe) { |
@@ -173,8 +173,8 @@ public class LstBuildConfigManager implements BuildConfigManager { | |||
} | |||
node.addChild(dir); | |||
// boolean foundMatch = false; | |||
for (Iterator it = importedFiles.iterator(); it.hasNext();) { | |||
File importedFile = (File) it.next(); | |||
for (Object file : importedFiles) { | |||
File importedFile = (File) file; | |||
if (importedFile.getParentFile().getAbsolutePath().equals(dir2.getAbsolutePath())) { | |||
// foundMatch = true; | |||
BuildConfigNode importedFileNode = new BuildConfigNode(importedFile.getName(), BuildConfigNode.Kind.FILE_LST, | |||
@@ -215,8 +215,8 @@ public class LstBuildConfigManager implements BuildConfigManager { | |||
} | |||
private void addFilesToDirTree(BuildConfigModel model, List configFiles, List badEntries) { | |||
for (Iterator it = configFiles.iterator(); it.hasNext();) { | |||
String path = (String) it.next(); | |||
for (Object configFile : configFiles) { | |||
String path = (String) configFile; | |||
if (path.startsWith("..")) { | |||
File file = new File(path); | |||
BuildConfigNode node = new BuildConfigNode(file.getName(), BuildConfigNode.Kind.FILE_JAVA, path); |
@@ -51,8 +51,7 @@ public class StructureSearchManager { | |||
} | |||
} | |||
if (node != null && node.getChildren() != null) { | |||
for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) { | |||
IProgramElement nextNode = it.next(); | |||
for (IProgramElement nextNode : node.getChildren()) { | |||
if (nextNode != null) { | |||
findMatchesHelper(nextNode, pattern, kind, matches); | |||
} |
@@ -83,8 +83,8 @@ public abstract class StructureView { | |||
} | |||
if (node != null && node.getChildren() != null) { | |||
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { | |||
IStructureViewNode foundNode = findCorrespondingViewNodeHelper((IStructureViewNode)it.next(), pNode); | |||
for (Object o : node.getChildren()) { | |||
IStructureViewNode foundNode = findCorrespondingViewNodeHelper((IStructureViewNode) o, pNode); | |||
if (foundNode != null) return foundNode; | |||
} | |||
} |
@@ -46,8 +46,8 @@ public class StructureViewManager { | |||
public void elementsUpdated(IHierarchy model) { | |||
// updating structure views: | |||
for (Iterator it = structureViews.iterator(); it.hasNext();) { | |||
treeViewBuilder.buildView((StructureView) it.next(), (AspectJElementHierarchy) model); | |||
for (Object structureView : structureViews) { | |||
treeViewBuilder.buildView((StructureView) structureView, (AspectJElementHierarchy) model); | |||
} | |||
} | |||
}; | |||
@@ -119,8 +119,8 @@ public class StructureViewManager { | |||
} | |||
} | |||
for (Iterator it = structureViews.iterator(); it.hasNext();) { | |||
StructureView view = (StructureView) it.next(); | |||
for (Object structureView : structureViews) { | |||
StructureView view = (StructureView) structureView; | |||
if (!(view instanceof GlobalStructureView) || !recordHistory || defaultFileView == null) { | |||
if (node.getKind().equals(IProgramElement.Kind.CODE)) { | |||
IProgramElement parentNode = node.getParent(); |
@@ -49,14 +49,13 @@ public abstract class StructureViewNodeFactory { | |||
IRelationshipMap relMap = (manager == null ? null : manager.getRelationshipMap()); | |||
List relationships = (relMap == null ? null : relMap.get(nodeHandle)); | |||
if (relationships != null) { | |||
for (Iterator it = relationships.iterator(); it.hasNext();) { | |||
IRelationship rel = (IRelationship) it.next(); | |||
for (Object relationship : relationships) { | |||
IRelationship rel = (IRelationship) relationship; | |||
if (rel != null && rel.getTargets().size() > 0) { | |||
IStructureViewNode relNode = createRelationship(rel, iconRegistry.getIcon(rel.getKind())); | |||
if (relNode != null) { | |||
svNode.add(relNode, 0); | |||
for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext();) { | |||
String handle = (String) it2.next(); | |||
for (String handle : rel.getTargets()) { | |||
IProgramElement link = Ajde.getDefault().getModel().getHierarchy().findElementForHandle(handle); | |||
if (link != null) { | |||
IStructureViewNode linkNode = createLink(link, iconRegistry.getStructureIcon(link.getKind(), |
@@ -197,8 +197,8 @@ public class TreeStructureViewBuilder { | |||
private void sortView(IStructureViewNode node, Comparator<IStructureViewNode> comparator) { | |||
if (node == null || node.getChildren() == null) return; | |||
Collections.sort(node.getChildren(), comparator); | |||
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { | |||
IStructureViewNode nextNode = (IStructureViewNode)it.next(); | |||
for (Object o : node.getChildren()) { | |||
IStructureViewNode nextNode = (IStructureViewNode) o; | |||
if (nextNode != null) sortView(nextNode, comparator); | |||
} | |||
} |
@@ -76,8 +76,8 @@ public class UserPreferencesStore implements UserPreferencesAdapter { | |||
@Override | |||
public void setProjectMultivalPreference(String name, List values) { | |||
String valuesString = ""; | |||
for (Iterator it = values.iterator(); it.hasNext(); ) { | |||
valuesString += (String)it.next() + ';'; | |||
for (Object value : values) { | |||
valuesString += (String) value + ';'; | |||
} | |||
properties.setProperty(name, valuesString); | |||
saveProperties(); |
@@ -67,10 +67,10 @@ public class JavaCompilerWarningsOptionsPanel extends OptionsPanel { | |||
public void saveOptions() throws IOException { | |||
Set s = warningComboBoxes.entrySet(); | |||
for (Iterator iterator = s.iterator(); iterator.hasNext();) { | |||
Map.Entry entry = (Entry) iterator.next(); | |||
for (Object o : s) { | |||
Entry entry = (Entry) o; | |||
String javaOption = (String) entry.getKey(); | |||
JComboBox combo = (JComboBox)entry.getValue(); | |||
JComboBox combo = (JComboBox) entry.getValue(); | |||
String value = (String) combo.getSelectedItem(); | |||
javaBuildOptions.setOption(javaOption, value); | |||
} |
@@ -72,8 +72,8 @@ public class BrowserStructureViewToolPanel extends JPanel { | |||
view_comboBox = new JComboBox(); | |||
view_comboBox.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT); | |||
for (Iterator it = structureViews.iterator(); it.hasNext(); ) { | |||
view_comboBox.addItem(it.next()); | |||
for (Object structureView : structureViews) { | |||
view_comboBox.addItem(structureView); | |||
} | |||
try { | |||
@@ -120,26 +120,26 @@ public class BrowserStructureViewToolPanel extends JPanel { | |||
private JPopupMenu createFilterMenu() { | |||
JPopupMenu filterMenu = new JPopupMenu(); | |||
IProgramElement.Accessibility[] accessibility = IProgramElement.Accessibility.ALL; | |||
for (int i = 0; i < accessibility.length; i++) { | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(accessibility[i]); | |||
menuItem.setIcon(Ajde.getDefault().getIconRegistry().getAccessibilitySwingIcon(accessibility[i])); | |||
for (IProgramElement.Accessibility value : accessibility) { | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(value); | |||
menuItem.setIcon(Ajde.getDefault().getIconRegistry().getAccessibilitySwingIcon(value)); | |||
filterMenu.add(menuItem); | |||
} | |||
filterMenu.add(new JSeparator()); | |||
IProgramElement.Kind[] kinds = IProgramElement.Kind.ALL; | |||
for (int i = 0; i < kinds.length; i++) { | |||
if (kinds[i].isMember()) { | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kinds[i]); | |||
menuItem.setIcon((Icon)Ajde.getDefault().getIconRegistry().getIcon(kinds[i]).getIconResource()); | |||
for (IProgramElement.Kind kind : kinds) { | |||
if (kind.isMember()) { | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kind); | |||
menuItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(kind).getIconResource()); | |||
filterMenu.add(menuItem); | |||
} | |||
} | |||
filterMenu.add(new JSeparator()); | |||
IProgramElement.Modifiers[] modifiers = IProgramElement.Modifiers.ALL; | |||
for (int i = 0; i < modifiers.length; i++) { | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(modifiers[i]); | |||
for (IProgramElement.Modifiers modifier : modifiers) { | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(modifier); | |||
filterMenu.add(menuItem); | |||
} | |||
return filterMenu; | |||
@@ -149,10 +149,10 @@ public class BrowserStructureViewToolPanel extends JPanel { | |||
JPopupMenu relationsMenu = new JPopupMenu(); | |||
java.util.List relations = Ajde.getDefault().getStructureViewManager().getAvailableRelations(); | |||
for (Iterator it = relations.iterator(); it.hasNext(); ) { | |||
IRelationship.Kind relation = (IRelationship.Kind)it.next(); | |||
for (Object o : relations) { | |||
IRelationship.Kind relation = (IRelationship.Kind) o; | |||
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(relation); | |||
menuItem.setIcon((Icon)Ajde.getDefault().getIconRegistry().getIcon(relation).getIconResource()); | |||
menuItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(relation).getIconResource()); | |||
relationsMenu.add(menuItem); | |||
} | |||
@@ -164,10 +164,10 @@ public class BrowserStructureViewToolPanel extends JPanel { | |||
StructureViewProperties.Granularity[] granularity = StructureViewProperties.Granularity.ALL; | |||
ButtonGroup group = new ButtonGroup(); | |||
for (int i = 0; i < granularity.length; i++) { | |||
RadioSelectionMenuButton menuItem = new RadioSelectionMenuButton(granularity[i], group); | |||
for (StructureViewProperties.Granularity value : granularity) { | |||
RadioSelectionMenuButton menuItem = new RadioSelectionMenuButton(value, group); | |||
orderMenu.add(menuItem); | |||
if (granularity[i].equals(StructureViewProperties.Granularity.MEMBER)) { | |||
if (value.equals(StructureViewProperties.Granularity.MEMBER)) { | |||
menuItem.setSelected(true); | |||
} | |||
} |
@@ -121,9 +121,9 @@ class BrowserView extends JPanel { | |||
public void updateConfigs(java.util.List configsList) { | |||
configs_comboBox.removeAllItems(); | |||
for (Iterator it = configsList.iterator(); it.hasNext(); ) { | |||
configs_comboBox.addItem(it.next()); | |||
} | |||
for (Object o : configsList) { | |||
configs_comboBox.addItem(o); | |||
} | |||
} | |||
public void setSelectedConfig(String config) { |
@@ -67,12 +67,12 @@ public class BrowserViewPanel extends JPanel implements StructureViewRenderer { | |||
public BrowserViewPanel(IconRegistry icons, java.util.List views, StructureViewProperties.Hierarchy visibleViewHierarchy) { | |||
try { | |||
view_comboBox = new JComboBox(views.toArray()); | |||
for (Iterator it = views.iterator(); it.hasNext(); ) { | |||
StructureViewProperties.Hierarchy hierarchy = (StructureViewProperties.Hierarchy)it.next(); | |||
if (hierarchy == visibleViewHierarchy) { | |||
view_comboBox.setSelectedItem(hierarchy); | |||
} | |||
} | |||
for (Object view : views) { | |||
StructureViewProperties.Hierarchy hierarchy = (StructureViewProperties.Hierarchy) view; | |||
if (hierarchy == visibleViewHierarchy) { | |||
view_comboBox.setSelectedItem(hierarchy); | |||
} | |||
} | |||
//GlobalViewProperties visibleView = (GlobalViewProperties)viewProperties.get(visibleViewHierarchy.toString()); | |||
treeManager = new StructureTreeManager();//, visibleView); | |||
jbInit(); |
@@ -39,23 +39,23 @@ public class BuildConfigPopupMenu extends JPopupMenu { | |||
public BuildConfigPopupMenu(final AbstractAction action) { | |||
List configFiles = Ajde.getDefault().getBuildConfigManager().getAllBuildConfigFiles(); | |||
for (Iterator it = configFiles.iterator(); it.hasNext(); ) { | |||
final String buildConfig = (String)it.next(); | |||
JMenuItem buildItem = new JMenuItem(buildConfig); | |||
buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT); | |||
buildItem.addActionListener( | |||
new ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(buildConfig); | |||
// A separate thread is required here because the buildProgresssMonitor | |||
// that monitors the build needs to be in a different thread | |||
// to that which is doing the build (swing threading issues) | |||
Ajde.getDefault().runBuildInDifferentThread(buildConfig, true); | |||
action.actionPerformed(e); | |||
} | |||
}); | |||
buildItem.setIcon((Icon)Ajde.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.FILE_LST).getIconResource()); | |||
this.add(buildItem); | |||
for (Object configFile : configFiles) { | |||
final String buildConfig = (String) configFile; | |||
JMenuItem buildItem = new JMenuItem(buildConfig); | |||
buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT); | |||
buildItem.addActionListener( | |||
new ActionListener() { | |||
public void actionPerformed(ActionEvent e) { | |||
Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(buildConfig); | |||
// A separate thread is required here because the buildProgresssMonitor | |||
// that monitors the build needs to be in a different thread | |||
// to that which is doing the build (swing threading issues) | |||
Ajde.getDefault().runBuildInDifferentThread(buildConfig, true); | |||
action.actionPerformed(e); | |||
} | |||
}); | |||
buildItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.FILE_LST).getIconResource()); | |||
this.add(buildItem); | |||
} | |||
} | |||
} |
@@ -160,9 +160,9 @@ public class OptionsFrame extends JFrame { | |||
private void saveOptions() { | |||
try { | |||
Component[] components = main_tabbedPane.getComponents(); | |||
for (int i = 0; i < components.length; i++) { | |||
if (components[i] instanceof OptionsPanel) { | |||
((OptionsPanel)components[i]).saveOptions(); | |||
for (Component component : components) { | |||
if (component instanceof OptionsPanel) { | |||
((OptionsPanel) component).saveOptions(); | |||
} | |||
} | |||
} catch (IOException ioe) { |
@@ -63,8 +63,8 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer | |||
public StructureViewPanel(java.util.List structureViews) { | |||
// this.structureViews = structureViews; | |||
for (Iterator it = structureViews.iterator(); it.hasNext(); ) { | |||
initView((StructureView)it.next()); | |||
for (Object structureView : structureViews) { | |||
initView((StructureView) structureView); | |||
} | |||
currentView = (StructureView)structureViews.get(0); | |||
structureToolBar_panel = new BrowserStructureViewToolPanel(structureViews, currentView, this); |
@@ -48,10 +48,10 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements IStruct | |||
this.kind = Kind.DECLARATION; | |||
if (children != null) { | |||
for (Iterator it = children.iterator(); it.hasNext(); ) { | |||
SwingTreeViewNode child = (SwingTreeViewNode)it.next(); | |||
for (Object o : children) { | |||
SwingTreeViewNode child = (SwingTreeViewNode) o; | |||
if (StructureViewNodeFactory.acceptNode(programElement, child.getStructureNode())) { | |||
super.add(child); | |||
super.add(child); | |||
} | |||
} | |||
} |
@@ -107,10 +107,9 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit | |||
private ConfigTreeNode buildTree(BuildConfigNode node) { | |||
ConfigTreeNode treeNode = new ConfigTreeNode(node); | |||
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { | |||
BuildConfigNode childNode = (BuildConfigNode)it.next(); | |||
treeNode.add(buildTree(childNode)); | |||
} | |||
for (BuildConfigNode childNode : node.getChildren()) { | |||
treeNode.add(buildTree(childNode)); | |||
} | |||
return treeNode; | |||
} | |||
@@ -91,8 +91,7 @@ public abstract class AjdeTestCase extends TestCase { | |||
String contents[] = from.list(); | |||
if (contents == null) | |||
return; | |||
for (int i = 0; i < contents.length; i++) { | |||
String string = contents[i]; | |||
for (String string : contents) { | |||
File f = new File(from, string); | |||
File t = new File(to, string); | |||
@@ -78,8 +78,7 @@ public class ExtensionTest extends AjcTestCase { | |||
private IProgramElement getChild(IProgramElement parent, String s) { | |||
List<IProgramElement> kids = parent.getChildren(); | |||
for (Iterator<IProgramElement> iter = kids.iterator(); iter.hasNext();) { | |||
IProgramElement element = (IProgramElement) iter.next(); | |||
for (IProgramElement element : kids) { | |||
if (element.getName().indexOf(s) != -1) | |||
return element; | |||
} | |||
@@ -97,8 +96,8 @@ public class ExtensionTest extends AjcTestCase { | |||
} | |||
if (ipe.getChildren() != null) { | |||
List kids = ipe.getChildren(); | |||
for (Iterator iter = kids.iterator(); iter.hasNext();) { | |||
IProgramElement element = (IProgramElement) iter.next(); | |||
for (Object kid : kids) { | |||
IProgramElement element = (IProgramElement) kid; | |||
findChild(s, element); | |||
} | |||
} | |||
@@ -113,8 +112,8 @@ public class ExtensionTest extends AjcTestCase { | |||
System.out.println(ipe.toLabelString());// getName()); | |||
if (ipe.getChildren() != null) { | |||
List kids = ipe.getChildren(); | |||
for (Iterator iter = kids.iterator(); iter.hasNext();) { | |||
IProgramElement element = (IProgramElement) iter.next(); | |||
for (Object kid : kids) { | |||
IProgramElement element = (IProgramElement) kid; | |||
walkit(element, indent + 2); | |||
} | |||
} |
@@ -98,8 +98,7 @@ public class StructureViewManagerTest extends AjdeTestCase { | |||
} | |||
private void testModelIntegrityHelper(IProgramElement node) throws Exception { | |||
for (Iterator it = node.getChildren().iterator(); it.hasNext();) { | |||
IProgramElement child = (IProgramElement) it.next(); | |||
for (IProgramElement child : node.getChildren()) { | |||
if (node == child.getParent()) { | |||
testModelIntegrityHelper(child); | |||
} else { |
@@ -77,18 +77,18 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { | |||
} | |||
public boolean containsMessage(String prefix,String distinguishingMarks) { | |||
for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) { | |||
String element = (String) iter.next(); | |||
for (Object o : messagesReceived) { | |||
String element = (String) o; | |||
if (element.startsWith(prefix) && | |||
element.indexOf(distinguishingMarks)!=-1) return true; | |||
element.indexOf(distinguishingMarks) != -1) return true; | |||
} | |||
return false; | |||
} | |||
public void dumpMessages() { | |||
System.out.println("ProgressMonitorMessages"); | |||
for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) { | |||
String element = (String) iter.next(); | |||
for (Object o : messagesReceived) { | |||
String element = (String) o; | |||
System.out.println(element); | |||
} | |||
} |
@@ -116,17 +116,17 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { | |||
/* Allow the user to override the testProjectPath by using sourceRoots */ | |||
File[] srcBase = new File[] { new File(projectPath + File.separator + srcDirName) }; | |||
for (int j = 0; j < srcBase.length; j++) { | |||
File[] fromResources = FileUtil.listFiles(srcBase[j], new FileFilter() { | |||
for (File file : srcBase) { | |||
File[] fromResources = FileUtil.listFiles(file, new FileFilter() { | |||
public boolean accept(File pathname) { | |||
String name = pathname.getName().toLowerCase(); | |||
return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj") | |||
&& !name.endsWith(".lst") && !name.endsWith(".jar"); | |||
} | |||
}); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
String normPath = FileUtil.normalizedPath(fromResources[i], srcBase[j]); | |||
sourcePathResources.put(normPath, fromResources[i]); | |||
for (File fromResource : fromResources) { | |||
String normPath = FileUtil.normalizedPath(fromResource, file); | |||
sourcePathResources.put(normPath, fromResource); | |||
} | |||
} |
@@ -58,8 +58,8 @@ class HtmlDecorator { | |||
rootDir = newRootDir; | |||
declIDTable = table; | |||
docVisibilityModifier = docModifier; | |||
for (int i = 0; i < inputFiles.length; i++) { | |||
decorateHTMLFromIPEs(getProgramElements(model, inputFiles[i].getCanonicalPath()), rootDir.getCanonicalPath() | |||
for (File inputFile : inputFiles) { | |||
decorateHTMLFromIPEs(getProgramElements(model, inputFile.getCanonicalPath()), rootDir.getCanonicalPath() | |||
+ Config.DIR_SEP_CHAR, docModifier, false); | |||
} | |||
} | |||
@@ -67,8 +67,7 @@ class HtmlDecorator { | |||
static void decorateHTMLFromIPEs(IProgramElement[] decls, String base, String docModifier, boolean exceededNestingLevel) | |||
throws IOException { | |||
if (decls != null) { | |||
for (int i = 0; i < decls.length; i++) { | |||
IProgramElement decl = decls[i]; | |||
for (IProgramElement decl : decls) { | |||
decorateHTMLFromIPE(decl, base, docModifier, exceededNestingLevel); | |||
} | |||
} | |||
@@ -311,8 +310,7 @@ class HtmlDecorator { | |||
if (fieldsDeclaredOn != null && !constDeclaredOn.isEmpty()) { | |||
insertDeclarationsSummary(fileBuffer, constDeclaredOn, ITD_CONSTRUCTOR_SUMMARY, index); | |||
} | |||
for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) { | |||
IProgramElement member = it.next(); | |||
for (IProgramElement member : node.getChildren()) { | |||
if (member.getKind().equals(IProgramElement.Kind.POINTCUT)) { | |||
pointcuts.add(member); | |||
} else if (member.getKind().equals(IProgramElement.Kind.ADVICE)) { | |||
@@ -365,8 +363,8 @@ class HtmlDecorator { | |||
insertIndex += tableHead.length(); | |||
// insert the body of the table | |||
for (int i = 0; i < decls.size(); i++) { | |||
IProgramElement decl = (IProgramElement) decls.get(i); | |||
for (Object o : decls) { | |||
IProgramElement decl = (IProgramElement) o; | |||
if (isAboveVisibility(decl)) { | |||
// insert the table row accordingly | |||
String comment = generateSummaryComment(decl); | |||
@@ -413,8 +411,8 @@ class HtmlDecorator { | |||
private static boolean declsAboveVisibilityExist(List decls) { | |||
boolean exist = false; | |||
for (Iterator it = decls.iterator(); it.hasNext();) { | |||
IProgramElement element = (IProgramElement) it.next(); | |||
for (Object decl : decls) { | |||
IProgramElement element = (IProgramElement) decl; | |||
if (isAboveVisibility(element)) | |||
exist = true; | |||
} | |||
@@ -810,11 +808,11 @@ class HtmlDecorator { | |||
static String generateHREFName(IProgramElement decl) { | |||
StringBuffer hrefLinkBuffer = new StringBuffer(); | |||
char[] declChars = decl.toLabelString().toCharArray(); | |||
for (int i = 0; i < declChars.length; i++) { | |||
if (declChars[i] == '"') { | |||
for (char declChar : declChars) { | |||
if (declChar == '"') { | |||
hrefLinkBuffer.append("quot;"); | |||
} else { | |||
hrefLinkBuffer.append(declChars[i]); | |||
hrefLinkBuffer.append(declChar); | |||
} | |||
} | |||
return hrefLinkBuffer.toString(); |
@@ -171,14 +171,14 @@ public class Main implements Config { | |||
*/ | |||
private static void packageHTML(AsmManager model, File[] inputFiles) throws IOException { | |||
ArrayList<String> dirList = new ArrayList<String>(); | |||
for (int i = 0; i < inputFiles.length; i++) { | |||
String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFiles[i]); | |||
for (File inputFile : inputFiles) { | |||
String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFile); | |||
// Only copy the package.html file once. | |||
if (dirList.contains(packageName)) | |||
continue; | |||
// Check to see if there exist a package.html file for this package. | |||
String dir = inputFiles[i].getAbsolutePath().substring(0, inputFiles[i].getAbsolutePath().lastIndexOf(File.separator)); | |||
String dir = inputFile.getAbsolutePath().substring(0, inputFile.getAbsolutePath().lastIndexOf(File.separator)); | |||
File input = new File(dir + Config.DIR_SEP_CHAR + "package.html"); | |||
File inDir = new File(dir + Config.DIR_SEP_CHAR + "doc-files"); | |||
// If it does not exist lets go to the next package. | |||
@@ -226,8 +226,8 @@ public class Main implements Config { | |||
for (; i < ajcOptions.size(); i++) { | |||
argsToCompiler[i] = ajcOptions.elementAt(i); | |||
} | |||
for (int j = 0; j < inputFiles.length; j++) { | |||
argsToCompiler[i] = inputFiles[j].getAbsolutePath(); | |||
for (File inputFile : inputFiles) { | |||
argsToCompiler[i] = inputFile.getAbsolutePath(); | |||
// System.out.println(">> file to ajc: " + inputFiles[j].getAbsolutePath()); | |||
i++; | |||
} | |||
@@ -281,8 +281,8 @@ public class Main implements Config { | |||
for (int k = 0; k < signatureFiles.length; k++) { | |||
javadocargs[options.size() + k] = StructureUtil.translateAjPathName(signatureFiles[k].getCanonicalPath()); | |||
} | |||
for (int k = 0; k < signatureFiles.length; k++) { | |||
files.add(StructureUtil.translateAjPathName(signatureFiles[k].getCanonicalPath())); | |||
for (File signatureFile : signatureFiles) { | |||
files.add(StructureUtil.translateAjPathName(signatureFile.getCanonicalPath())); | |||
} | |||
} | |||
if (LangUtil.is19VMOrGreater()) { | |||
@@ -321,8 +321,8 @@ public class Main implements Config { | |||
return f.getName().equals("package-summary.html"); | |||
} | |||
}); | |||
for (int j = 0; j < files.length; j++) { | |||
removeDeclIDsFromFile(files[j].getAbsolutePath(), false); | |||
for (File file : files) { | |||
removeDeclIDsFromFile(file.getAbsolutePath(), false); | |||
} | |||
} | |||
} | |||
@@ -478,8 +478,8 @@ public class Main implements Config { | |||
// System.err.println(argList); | |||
args = new String[argList.size()]; | |||
int counter = 0; | |||
for (Iterator<String> it = argList.iterator(); it.hasNext();) { | |||
args[counter] = it.next(); | |||
for (String s : argList) { | |||
args[counter] = s; | |||
counter++; | |||
} | |||
} catch (FileNotFoundException e) { | |||
@@ -530,8 +530,8 @@ public class Main implements Config { | |||
if (vargs.size() == 0) { | |||
displayHelpAndExit(null); | |||
} | |||
for (int i = 0; i < vargs.size(); i++) { | |||
String arg = (String) vargs.get(i); | |||
for (Object varg : vargs) { | |||
String arg = (String) varg; | |||
ignoreArg = false; | |||
if (addNextAsDocDir) { | |||
docDir = arg; | |||
@@ -694,16 +694,16 @@ public class Main implements Config { | |||
int index2 = name.length(); | |||
if ((index1 >= 0 && index2 >= 0) | |||
&& (name.substring(index1, index2).equals(".java") || name.substring(index1, index2) | |||
.equals(".aj"))) { | |||
.equals(".aj"))) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
}); | |||
for (int j = 0; j < files.length; j++) { | |||
for (String file : files) { | |||
filenames.addElement(sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg | |||
+ Config.DIR_SEP_CHAR + files[j]); | |||
+ Config.DIR_SEP_CHAR + file); | |||
} | |||
} else if (c == sourcepath.size()) { // last element on classpath | |||
System.out.println("ajdoc: No package, class, or source file " + "found named " + arg + "."); |
@@ -47,16 +47,14 @@ public class StructureUtil { | |||
if (rels != null) { | |||
relations.addAll(rels); | |||
} | |||
for (Iterator<IProgramElement> iter = node.getChildren().iterator(); iter.hasNext();) { | |||
IProgramElement child = (IProgramElement) iter.next(); | |||
for (IProgramElement child : node.getChildren()) { | |||
// if we're not a type, or if we are and the child is code, then | |||
// we want to get the relationships for this child - this means that the | |||
// correct relationships appear against the type in the ajdoc | |||
if (!node.getKind().isType() || child.getKind().equals(IProgramElement.Kind.CODE)) { | |||
List<IRelationship> childRelations = node.getModel().getRelationshipMap().get(child); | |||
if (childRelations != null) { | |||
for (Iterator<IRelationship> iterator = childRelations.iterator(); iterator.hasNext();) { | |||
IRelationship rel = (IRelationship) iterator.next(); | |||
for (IRelationship rel : childRelations) { | |||
if (!relations.contains(rel)) { | |||
relations.add(rel); | |||
} | |||
@@ -67,11 +65,10 @@ public class StructureUtil { | |||
if (relations == null || relations.isEmpty()) | |||
return null; | |||
List<String> targets = new ArrayList<String>(); | |||
for (Iterator<IRelationship> it = relations.iterator(); it.hasNext();) { | |||
IRelationship rtn = (IRelationship) it.next(); | |||
for (IRelationship rtn : relations) { | |||
if (rtn.getKind().equals(kind) && ((relName != null && relName.equals(rtn.getName())) || relName == null)) { | |||
List<String> targs = rtn.getTargets(); | |||
for (String element: targs) { | |||
for (String element : targs) { | |||
if (!targets.contains(element)) { | |||
targets.add(element); | |||
} | |||
@@ -125,8 +122,8 @@ public class StructureUtil { | |||
} | |||
String modifiers = ""; | |||
for (Iterator modIt = node.getModifiers().iterator(); modIt.hasNext();) { | |||
modifiers += modIt.next() + " "; | |||
for (IProgramElement.Modifiers value : node.getModifiers()) { | |||
modifiers += value + " "; | |||
} | |||
if (node.getKind().equals(IProgramElement.Kind.METHOD) || node.getKind().equals(IProgramElement.Kind.FIELD)) { |
@@ -59,8 +59,7 @@ class StubFileGenerator { | |||
} | |||
IProgramElement fileNode = model.getHierarchy().findElementForSourceFile(inputFile.getAbsolutePath()); | |||
for (Iterator it = fileNode.getChildren().iterator(); it.hasNext();) { | |||
IProgramElement node = (IProgramElement) it.next(); | |||
for (IProgramElement node : fileNode.getChildren()) { | |||
if (node.getKind().isPackageDeclaration()) { | |||
// skip | |||
} else if (node.getKind().equals(IProgramElement.Kind.IMPORT_REFERENCE)) { | |||
@@ -84,8 +83,8 @@ class StubFileGenerator { | |||
private static void processImportDeclaration(IProgramElement node, PrintWriter writer) throws IOException { | |||
List imports = node.getChildren(); | |||
for (Iterator i = imports.iterator(); i.hasNext();) { | |||
IProgramElement importNode = (IProgramElement) i.next(); | |||
for (Object anImport : imports) { | |||
IProgramElement importNode = (IProgramElement) anImport; | |||
writer.println(importNode.getSourceSignature()); | |||
} | |||
} | |||
@@ -111,8 +110,8 @@ class StubFileGenerator { | |||
private static void processMembers(List/* IProgramElement */members, PrintWriter writer, boolean declaringTypeIsInterface) | |||
throws DocException { | |||
for (Iterator it = members.iterator(); it.hasNext();) { | |||
IProgramElement member = (IProgramElement) it.next(); | |||
for (Object o : members) { | |||
IProgramElement member = (IProgramElement) o; | |||
if (member.getKind().isType()) { | |||
if (!member.getParent().getKind().equals(IProgramElement.Kind.METHOD) && !StructureUtil.isAnonymous(member)) {// don't |
@@ -61,8 +61,7 @@ public class AjdocOutputChecker { | |||
*/ | |||
public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception { | |||
List<String> missingStrings = new ArrayList<String>(); | |||
for (int i = 0; i < requiredStrings.length; i++) { | |||
String string = requiredStrings[i]; | |||
for (String string : requiredStrings) { | |||
if (!containsString(htmlFile, string)) { | |||
missingStrings.add(string); | |||
} | |||
@@ -122,9 +121,8 @@ public class AjdocOutputChecker { | |||
public static List<String> getMissingStringsInSection(File htmlFile, | |||
String[] requiredStrings, String sectionHeader) throws Exception { | |||
List<String> missingStrings = new ArrayList<String>(); | |||
for (int i = 0; i < requiredStrings.length; i++) { | |||
String string = requiredStrings[i]; | |||
if (!containsStringWithinSection(htmlFile,string,sectionHeader)) { | |||
for (String string : requiredStrings) { | |||
if (!containsStringWithinSection(htmlFile, string, sectionHeader)) { | |||
missingStrings.add(string); | |||
} | |||
} |
@@ -97,8 +97,7 @@ public abstract class AjdocTestCase extends TestCase { | |||
String contents[] = from.list(); | |||
if (contents == null) | |||
return; | |||
for (int i = 0; i < contents.length; i++) { | |||
String string = contents[i]; | |||
for (String string : contents) { | |||
File f = new File(from, string); | |||
File t = new File(to, string); | |||
@@ -209,9 +208,9 @@ public abstract class AjdocTestCase extends TestCase { | |||
if (inputFiles.length == 0) { | |||
fail("need to pass some files into ajdoc"); | |||
} | |||
for (int i = 0; i < inputFiles.length; i++) { | |||
if (!inputFiles[i].exists()) { | |||
fail(inputFiles[i].getAbsolutePath() + " does not exist"); | |||
for (File inputFile : inputFiles) { | |||
if (!inputFile.exists()) { | |||
fail(inputFile.getAbsolutePath() + " does not exist"); | |||
} | |||
} | |||
@@ -305,8 +304,8 @@ public abstract class AjdocTestCase extends TestCase { | |||
public void runAjdoc(List options) { | |||
String[] args = new String[options.size()]; | |||
int i = 0; | |||
for (Iterator iter = options.iterator(); iter.hasNext();) { | |||
String element = (String) iter.next(); | |||
for (Object option : options) { | |||
String element = (String) option; | |||
args[i] = element; | |||
i++; | |||
} |
@@ -157,8 +157,7 @@ public class AsmManager implements IStructureModel { | |||
IProgramElement fileNode = node; | |||
ArrayList<IProgramElement> peNodes = new ArrayList<IProgramElement>(); | |||
getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); | |||
for (Iterator<IProgramElement> it = peNodes.iterator(); it.hasNext();) { | |||
IProgramElement peNode = it.next(); | |||
for (IProgramElement peNode : peNodes) { | |||
List<IProgramElement> entries = new ArrayList<IProgramElement>(); | |||
entries.add(peNode); | |||
ISourceLocation sourceLoc = peNode.getSourceLocation(); | |||
@@ -733,8 +732,8 @@ public class AsmManager implements IStructureModel { | |||
if (relationshipsToRemove.size() == relationships.size()) { | |||
sourcesToRemove.add(hid); | |||
} else { | |||
for (int i = 0; i < relationshipsToRemove.size(); i++) { | |||
relationships.remove(relationshipsToRemove.get(i)); | |||
for (IRelationship iRelationship : relationshipsToRemove) { | |||
relationships.remove(iRelationship); | |||
} | |||
} | |||
} | |||
@@ -815,8 +814,8 @@ public class AsmManager implements IStructureModel { | |||
if (relationshipsToRemove.size() == relationships.size()) { | |||
sourcesToRemove.add(hid); | |||
} else { | |||
for (int i = 0; i < relationshipsToRemove.size(); i++) { | |||
relationships.remove(relationshipsToRemove.get(i)); | |||
for (IRelationship iRelationship : relationshipsToRemove) { | |||
relationships.remove(iRelationship); | |||
} | |||
} | |||
} | |||
@@ -960,15 +959,13 @@ public class AsmManager implements IStructureModel { | |||
List<IRelationship> relationshipsToRemove = new ArrayList<IRelationship>(); | |||
// Iterate through the relationships against this source | |||
// handle | |||
for (Iterator<IRelationship> reliter = relationships.iterator(); reliter.hasNext();) { | |||
IRelationship rel = reliter.next(); | |||
for (IRelationship rel : relationships) { | |||
List<String> targets = rel.getTargets(); | |||
List<String> targetsToRemove = new ArrayList<String>(); | |||
// Iterate through the targets for this relationship | |||
for (Iterator<String> targetIter = targets.iterator(); targetIter.hasNext();) { | |||
String targethid = targetIter.next(); | |||
// tgthandlecounter++; | |||
for (String targethid : targets) { | |||
// tgthandlecounter++; | |||
// Do we already know it doesn't exist? | |||
if (nonExistingHandles.contains(targethid)) { | |||
if (dumpDeltaProcessing) { | |||
@@ -1040,8 +1037,7 @@ public class AsmManager implements IStructureModel { | |||
} else { | |||
// MEMORY LEAK - we don't remove the | |||
// relationships !! | |||
for (int i = 0; i < relationshipsToRemove.size(); i++) { | |||
IRelationship irel = relationshipsToRemove.get(i); | |||
for (IRelationship irel : relationshipsToRemove) { | |||
verifyAssumption(mapper.remove(hid, irel), "Failed to remove relationship " + irel.getName() | |||
+ " for shid " + hid); | |||
} | |||
@@ -1055,8 +1051,7 @@ public class AsmManager implements IStructureModel { | |||
} | |||
} | |||
// Remove sources that have no valid relationships any more | |||
for (Iterator<String> srciter = sourcesToRemove.iterator(); srciter.hasNext();) { | |||
String hid = srciter.next(); | |||
for (String hid : sourcesToRemove) { | |||
mapper.removeAll(hid); | |||
IProgramElement ipe = hierarchy.getElement(hid); | |||
if (ipe != null) { |
@@ -330,11 +330,11 @@ public interface IProgramElement extends Serializable { | |||
}; | |||
public static Kind getKindForString(String kindString) { | |||
for (int i = 0; i < ALL.length; i++) { | |||
if (ALL[i].toString().equals(kindString)) { | |||
return ALL[i]; | |||
} | |||
} | |||
for (Kind kind : ALL) { | |||
if (kind.toString().equals(kindString)) { | |||
return kind; | |||
} | |||
} | |||
return ERROR; | |||
} | |||
@@ -75,9 +75,9 @@ public interface IRelationship extends Serializable { | |||
* @return the Kind instance | |||
*/ | |||
public static Kind getKindFor(String stringFormOfRelationshipKind) { | |||
for (int i = 0; i < ALL.length; i++) { | |||
if (ALL[i].name.equals(stringFormOfRelationshipKind)) { | |||
return ALL[i]; | |||
for (Kind kind : ALL) { | |||
if (kind.name.equals(stringFormOfRelationshipKind)) { | |||
return kind; | |||
} | |||
} | |||
return null; |
@@ -136,8 +136,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { | |||
List<char[]> parameterTypes = ipe.getParameterSignatures(); | |||
StringBuffer sb = new StringBuffer(); | |||
if (sourceRefs != null) { | |||
for (int i = 0; i < sourceRefs.size(); i++) { | |||
String sourceRef = sourceRefs.get(i); | |||
for (String sourceRef : sourceRefs) { | |||
sb.append(HandleProviderDelimiter.getDelimiter(ipe)); | |||
sb.append(sourceRef); | |||
} | |||
@@ -164,8 +163,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider { | |||
if (ipe.getKind().isInterTypeMember()) { | |||
int count = 1; | |||
List<IProgramElement> kids = ipe.getParent().getChildren(); | |||
for (Iterator<IProgramElement> iterator = kids.iterator(); iterator.hasNext();) { | |||
IProgramElement object = iterator.next(); | |||
for (IProgramElement object : kids) { | |||
if (object.equals(ipe)) { | |||
break; | |||
} |
@@ -544,8 +544,8 @@ public class ProgramElement implements IProgramElement { | |||
if (children == null) { | |||
return; | |||
} | |||
for (Iterator<IProgramElement> it = children.iterator(); it.hasNext();) { | |||
(it.next()).setParent(this); | |||
for (IProgramElement child : children) { | |||
child.setParent(this); | |||
} | |||
} | |||
@@ -751,8 +751,7 @@ public class ProgramElement implements IProgramElement { | |||
return Collections.emptyList(); | |||
} | |||
List<char[]> params = new ArrayList<char[]>(); | |||
for (Iterator<char[]> iter = l.iterator(); iter.hasNext();) { | |||
char[] param = iter.next(); | |||
for (char[] param : l) { | |||
params.add(NameConvertor.convertFromSignature(param)); | |||
} | |||
return params; |
@@ -62,8 +62,7 @@ public class RelationshipMap extends HashMap<String, List<IRelationship>> implem | |||
super.put(source, relationships); | |||
return rel; | |||
} else { | |||
for (Iterator<IRelationship> it = relationships.iterator(); it.hasNext();) { | |||
IRelationship curr = it.next(); | |||
for (IRelationship curr : relationships) { | |||
if (curr.getKind() == kind && curr.getName().equals(relationshipName) && curr.hasRuntimeTest() == runtimeTest) { | |||
return curr; | |||
} |
@@ -30,57 +30,57 @@ public class AttributeUtils { | |||
file.writeShort(0); | |||
} else { | |||
file.writeShort(attributes.length); | |||
for (int i = 0; i < attributes.length; i++) { | |||
attributes[i].dump(file); | |||
for (Attribute attribute : attributes) { | |||
attribute.dump(file); | |||
} | |||
} | |||
} | |||
public static Signature getSignatureAttribute(Attribute[] attributes) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_SIGNATURE) { | |||
return (Signature) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_SIGNATURE) { | |||
return (Signature) attribute; | |||
} | |||
} | |||
return null; | |||
} | |||
public static Code getCodeAttribute(Attribute[] attributes) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_CODE) { | |||
return (Code) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_CODE) { | |||
return (Code) attribute; | |||
} | |||
} | |||
return null; | |||
} | |||
public static ExceptionTable getExceptionTableAttribute(Attribute[] attributes) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_EXCEPTIONS) { | |||
return (ExceptionTable) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_EXCEPTIONS) { | |||
return (ExceptionTable) attribute; | |||
} | |||
} | |||
return null; | |||
} | |||
public static ConstantValue getConstantValueAttribute(Attribute[] attributes) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].getTag() == Constants.ATTR_CONSTANT_VALUE) { | |||
return (ConstantValue) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.getTag() == Constants.ATTR_CONSTANT_VALUE) { | |||
return (ConstantValue) attribute; | |||
} | |||
} | |||
return null; | |||
} | |||
public static void accept(Attribute[] attributes, ClassVisitor visitor) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
attributes[i].accept(visitor); | |||
for (Attribute attribute : attributes) { | |||
attribute.accept(visitor); | |||
} | |||
} | |||
public static boolean hasSyntheticAttribute(Attribute[] attributes) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_SYNTHETIC) { | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_SYNTHETIC) { | |||
return true; | |||
} | |||
} | |||
@@ -88,9 +88,9 @@ public class AttributeUtils { | |||
} | |||
public static SourceFile getSourceFileAttribute(Attribute[] attributes) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_SOURCE_FILE) { | |||
return (SourceFile) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_SOURCE_FILE) { | |||
return (SourceFile) attribute; | |||
} | |||
} | |||
return null; |
@@ -133,8 +133,8 @@ public final class BootstrapMethods extends Attribute { | |||
file.writeShort(bootstrapMethodRef); | |||
int len = bootstrapArguments.length; | |||
file.writeShort(len); | |||
for (int i=0;i<len;i++) { | |||
file.writeShort(bootstrapArguments[i]); | |||
for (int bootstrapArgument : bootstrapArguments) { | |||
file.writeShort(bootstrapArgument); | |||
} | |||
} | |||
@@ -192,8 +192,8 @@ public final class BootstrapMethods extends Attribute { | |||
} else { | |||
int blen = bootstrapMethods.length; | |||
file.writeShort(blen); | |||
for (int i = 0; i < blen; i++) { | |||
bootstrapMethods[i].dump(file); | |||
for (BootstrapMethod bootstrapMethod : bootstrapMethods) { | |||
bootstrapMethod.dump(file); | |||
} | |||
} | |||
} | |||
@@ -224,8 +224,8 @@ public final class BootstrapMethods extends Attribute { | |||
int [] args = bm.getBootstrapArguments(); | |||
line.append(" argcount:").append(args==null?0:args.length).append(" "); | |||
if (args!=null) { | |||
for (int a=0;a<args.length;a++) { | |||
line.append(args[a]).append("(").append(getConstantPool().getConstant(args[a])).append(") "); | |||
for (int arg : args) { | |||
line.append(arg).append("(").append(getConstantPool().getConstant(arg)).append(") "); | |||
} | |||
} | |||
@@ -173,13 +173,13 @@ public final class Code extends Attribute { | |||
file.write(code, 0, code.length); | |||
file.writeShort(exceptionTable.length); | |||
for (int i = 0; i < exceptionTable.length; i++) { | |||
exceptionTable[i].dump(file); | |||
for (CodeException e : exceptionTable) { | |||
e.dump(file); | |||
} | |||
file.writeShort(attributes.length); | |||
for (int i = 0; i < attributes.length; i++) { | |||
attributes[i].dump(file); | |||
for (Attribute attribute : attributes) { | |||
attribute.dump(file); | |||
} | |||
} | |||
@@ -195,9 +195,9 @@ public final class Code extends Attribute { | |||
* @return LineNumberTable of Code, if it has one | |||
*/ | |||
public LineNumberTable getLineNumberTable() { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_LINE_NUMBER_TABLE) { | |||
return (LineNumberTable) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_LINE_NUMBER_TABLE) { | |||
return (LineNumberTable) attribute; | |||
} | |||
} | |||
return null; | |||
@@ -207,9 +207,9 @@ public final class Code extends Attribute { | |||
* @return LocalVariableTable of Code, if it has one | |||
*/ | |||
public LocalVariableTable getLocalVariableTable() { | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i].tag == Constants.ATTR_LOCAL_VARIABLE_TABLE) { | |||
return (LocalVariableTable) attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute.tag == Constants.ATTR_LOCAL_VARIABLE_TABLE) { | |||
return (LocalVariableTable) attribute; | |||
} | |||
} | |||
return null; | |||
@@ -262,8 +262,8 @@ public final class Code extends Attribute { | |||
private final int calculateLength() { | |||
int len = 0; | |||
if (attributes != null) { | |||
for (int i = 0; i < attributes.length; i++) { | |||
len += attributes[i].length + 6 /* attribute header size */; | |||
for (Attribute attribute : attributes) { | |||
len += attribute.length + 6 /* attribute header size */; | |||
} | |||
} | |||
return len + getInternalLength(); | |||
@@ -317,16 +317,16 @@ public final class Code extends Attribute { | |||
if (exceptionTable.length > 0) { | |||
buf.append("\nException handler(s) = \n" + "From\tTo\tHandler\tType\n"); | |||
for (int i = 0; i < exceptionTable.length; i++) { | |||
buf.append(exceptionTable[i].toString(cpool, verbose) + "\n"); | |||
for (CodeException e : exceptionTable) { | |||
buf.append(e.toString(cpool, verbose) + "\n"); | |||
} | |||
} | |||
if (attributes.length > 0) { | |||
buf.append("\nAttribute(s) = \n"); | |||
for (int i = 0; i < attributes.length; i++) { | |||
buf.append(attributes[i].toString() + "\n"); | |||
for (Attribute attribute : attributes) { | |||
buf.append(attribute.toString() + "\n"); | |||
} | |||
} | |||
@@ -372,8 +372,7 @@ public final class Code extends Attribute { | |||
codeString.append(Utility.codeToString(code, cpool, 0, -1, true)); | |||
if (exceptionTable.length > 0) { | |||
codeString.append("\n").append("Exception entries = ").append(exceptionTable.length).append("\n"); | |||
for (int i = 0; i < exceptionTable.length; i++) { | |||
CodeException exc = exceptionTable[i]; | |||
for (CodeException exc : exceptionTable) { | |||
int type = exc.getCatchType(); | |||
String name = "finally"; | |||
if (type != 0) { |
@@ -168,8 +168,7 @@ public abstract class FieldOrMethod extends Modifiers implements Node { | |||
if (annotations == null) { | |||
// Find attributes that contain annotation data | |||
List<AnnotationGen> accumulatedAnnotations = new ArrayList<AnnotationGen>(); | |||
for (int i = 0; i < attributes.length; i++) { | |||
Attribute attribute = attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute instanceof RuntimeAnnos) { | |||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute; | |||
accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations()); |
@@ -260,18 +260,18 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
file.writeShort(superclassnameIdx); | |||
file.writeShort(interfaces.length); | |||
for (int i = 0; i < interfaces.length; i++) { | |||
file.writeShort(interfaces[i]); | |||
for (int anInterface : interfaces) { | |||
file.writeShort(anInterface); | |||
} | |||
file.writeShort(fields.length); | |||
for (int i = 0; i < fields.length; i++) { | |||
fields[i].dump(file); | |||
for (Field field : fields) { | |||
field.dump(file); | |||
} | |||
file.writeShort(methods.length); | |||
for (int i = 0; i < methods.length; i++) { | |||
methods[i].dump(file); | |||
for (Method method : methods) { | |||
method.dump(file); | |||
} | |||
AttributeUtils.writeAttributes(attributes, file); | |||
@@ -287,8 +287,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
if (annotationsOutOfDate) { | |||
// Find attributes that contain annotation data | |||
List<AnnotationGen> accumulatedAnnotations = new ArrayList<AnnotationGen>(); | |||
for (int i = 0; i < attributes.length; i++) { | |||
Attribute attribute = attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
if (attribute instanceof RuntimeAnnos) { | |||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute; | |||
accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations()); | |||
@@ -366,9 +365,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
* @return A org.aspectj.apache.bcel.classfile.Method corresponding to java.lang.reflect.Method if any | |||
*/ | |||
public Method getMethod(java.lang.reflect.Method m) { | |||
for (int i = 0; i < methods.length; i++) { | |||
Method method = methods[i]; | |||
for (Method method : methods) { | |||
if (m.getName().equals(method.getName()) && m.getModifiers() == method.getModifiers() | |||
&& Type.getSignature(m).equals(method.getSignature())) { | |||
return method; | |||
@@ -379,8 +376,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
} | |||
public Method getMethod(java.lang.reflect.Constructor<?> c) { | |||
for (int i = 0; i < methods.length; i++) { | |||
Method method = methods[i]; | |||
for (Method method : methods) { | |||
if (method.getName().equals("<init>") && c.getModifiers() == method.getModifiers() | |||
&& Type.getSignature(c).equals(method.getSignature())) { | |||
return method; | |||
@@ -552,29 +548,29 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
if (attributes.length > 0) { | |||
buf.append("\nAttribute(s):\n"); | |||
for (int i = 0; i < attributes.length; i++) { | |||
buf.append(indent(attributes[i])); | |||
for (Attribute attribute : attributes) { | |||
buf.append(indent(attribute)); | |||
} | |||
} | |||
if (annotations != null && annotations.length > 0) { | |||
buf.append("\nAnnotation(s):\n"); | |||
for (int i = 0; i < annotations.length; i++) { | |||
buf.append(indent(annotations[i])); | |||
for (AnnotationGen annotation : annotations) { | |||
buf.append(indent(annotation)); | |||
} | |||
} | |||
if (fields.length > 0) { | |||
buf.append("\n" + fields.length + " fields:\n"); | |||
for (int i = 0; i < fields.length; i++) { | |||
buf.append("\t" + fields[i] + '\n'); | |||
for (Field field : fields) { | |||
buf.append("\t" + field + '\n'); | |||
} | |||
} | |||
if (methods.length > 0) { | |||
buf.append("\n" + methods.length + " methods:\n"); | |||
for (int i = 0; i < methods.length; i++) { | |||
buf.append("\t" + methods[i] + '\n'); | |||
for (Method method : methods) { | |||
buf.append("\t" + method + '\n'); | |||
} | |||
} | |||
@@ -615,12 +611,12 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
return; | |||
} | |||
// Attribute[] attrs = attributes.getAttributes(); | |||
for (int i = 0; i < attributes.length; i++) { | |||
if (attributes[i] instanceof InnerClasses) { | |||
InnerClass[] innerClasses = ((InnerClasses) attributes[i]).getInnerClasses(); | |||
for (int j = 0; j < innerClasses.length; j++) { | |||
for (Attribute attribute : attributes) { | |||
if (attribute instanceof InnerClasses) { | |||
InnerClass[] innerClasses = ((InnerClasses) attribute).getInnerClasses(); | |||
for (InnerClass innerClass : innerClasses) { | |||
boolean innerClassAttributeRefersToMe = false; | |||
String inner_class_name = cpool.getConstantString(innerClasses[j].getInnerClassIndex(), | |||
String inner_class_name = cpool.getConstantString(innerClass.getInnerClassIndex(), | |||
Constants.CONSTANT_Class); | |||
inner_class_name = Utility.compactClassName(inner_class_name); | |||
if (inner_class_name.equals(getClassName())) { | |||
@@ -628,7 +624,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
} | |||
if (innerClassAttributeRefersToMe) { | |||
this.isNested = true; | |||
if (innerClasses[j].getInnerNameIndex() == 0) { | |||
if (innerClass.getInnerNameIndex() == 0) { | |||
this.isAnonymous = true; | |||
} | |||
} | |||
@@ -684,8 +680,8 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
JavaClass[] super_classes = getSuperClasses(); | |||
for (int i = 0; i < super_classes.length; i++) { | |||
if (super_classes[i].equals(super_class)) { | |||
for (JavaClass superClass : super_classes) { | |||
if (superClass.equals(super_class)) { | |||
return true; | |||
} | |||
} | |||
@@ -795,8 +791,8 @@ public class JavaClass extends Modifiers implements Cloneable, Node { | |||
} | |||
} | |||
for (int i = 0; i < interfaces.length; i++) { | |||
queue.add(interfaces[i]); | |||
for (JavaClass anInterface : interfaces) { | |||
queue.add(anInterface); | |||
} | |||
} | |||
@@ -165,11 +165,10 @@ public final class Method extends FieldOrMethod { | |||
signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable()); | |||
buf = new StringBuffer(signature); | |||
for (int i = 0; i < attributes.length; i++) { | |||
Attribute a = attributes[i]; | |||
if (!((a instanceof Code) || (a instanceof ExceptionTable))) | |||
buf.append(" [" + a.toString() + "]"); | |||
} | |||
for (Attribute a : attributes) { | |||
if (!((a instanceof Code) || (a instanceof ExceptionTable))) | |||
buf.append(" [" + a.toString() + "]"); | |||
} | |||
ExceptionTable e = getExceptionTable(); | |||
if (e != null) { | |||
@@ -212,14 +211,14 @@ public final class Method extends FieldOrMethod { | |||
// Find attributes that contain annotation data | |||
Attribute[] attrs = getAttributes(); | |||
for (int i = 0; i < attrs.length; i++) { | |||
Attribute attribute = attrs[i]; | |||
if (attribute instanceof RuntimeVisParamAnnos) { | |||
parameterAnnotationsVis = (RuntimeVisParamAnnos) attribute; | |||
} else if (attribute instanceof RuntimeInvisParamAnnos) { | |||
parameterAnnotationsInvis = (RuntimeInvisParamAnnos) attribute; | |||
} | |||
} | |||
for (Attribute attribute : attrs) { | |||
if (attribute instanceof RuntimeVisParamAnnos) { | |||
parameterAnnotationsVis = (RuntimeVisParamAnnos) attribute; | |||
} | |||
else if (attribute instanceof RuntimeInvisParamAnnos) { | |||
parameterAnnotationsInvis = (RuntimeInvisParamAnnos) attribute; | |||
} | |||
} | |||
boolean foundSome = false; | |||
// Build a list of annotation arrays, one per argument |
@@ -438,10 +438,10 @@ public final class Module extends Attribute { | |||
file.writeShort(moduleVersionIndex); | |||
file.writeShort(requires.length); | |||
for (int i = 0; i < requires.length; i++) { | |||
file.writeShort(requires[i].moduleIndex); | |||
file.writeShort(requires[i].flags); | |||
file.writeShort(requires[i].versionIndex); | |||
for (Require require : requires) { | |||
file.writeShort(require.moduleIndex); | |||
file.writeShort(require.flags); | |||
file.writeShort(require.versionIndex); | |||
} | |||
file.writeShort(exports.length); | |||
for (Export export : exports) { |
@@ -97,8 +97,8 @@ public final class ModulePackages extends Attribute { | |||
public final void dump(DataOutputStream stream) throws IOException { | |||
super.dump(stream); | |||
stream.writeShort(packageIndices.length); | |||
for (int i = 0; i < packageIndices.length; i++) { | |||
stream.writeShort(packageIndices[i]); | |||
for (int packageIndex : packageIndices) { | |||
stream.writeShort(packageIndex); | |||
} | |||
} | |||
@@ -117,8 +117,8 @@ public final class ModulePackages extends Attribute { | |||
@Override | |||
public final String toString() { | |||
StringBuffer buf = new StringBuffer(); | |||
for (int i = 0; i < packageIndices.length; i++) { | |||
buf.append(cpool.getPackageName(packageIndices[i]) + "\n"); | |||
for (int packageIndex : packageIndices) { | |||
buf.append(cpool.getPackageName(packageIndex) + "\n"); | |||
} | |||
return buf.toString(); | |||
} |
@@ -522,26 +522,26 @@ public abstract class Utility { | |||
char[] ch = label.toCharArray(); | |||
StringBuffer buf = new StringBuffer(); | |||
for (int i = 0; i < ch.length; i++) { | |||
switch (ch[i]) { | |||
case '\n': | |||
buf.append("\\n"); | |||
break; | |||
case '\r': | |||
buf.append("\\r"); | |||
break; | |||
case '\"': | |||
buf.append("\\\""); | |||
break; | |||
case '\'': | |||
buf.append("\\'"); | |||
break; | |||
case '\\': | |||
buf.append("\\\\"); | |||
break; | |||
default: | |||
buf.append(ch[i]); | |||
break; | |||
for (char c : ch) { | |||
switch (c) { | |||
case '\n': | |||
buf.append("\\n"); | |||
break; | |||
case '\r': | |||
buf.append("\\r"); | |||
break; | |||
case '\"': | |||
buf.append("\\\""); | |||
break; | |||
case '\'': | |||
buf.append("\\'"); | |||
break; | |||
case '\\': | |||
buf.append("\\\\"); | |||
break; | |||
default: | |||
buf.append(c); | |||
break; | |||
} | |||
} | |||
@@ -82,8 +82,7 @@ public class AnnotationGen { | |||
public void dump(DataOutputStream dos) throws IOException { | |||
dos.writeShort(typeIndex); // u2 index of type name in cpool | |||
dos.writeShort(pairs.size()); // u2 element_value pair count | |||
for (int i = 0; i < pairs.size(); i++) { | |||
NameValuePair envp = pairs.get(i); | |||
for (NameValuePair envp : pairs) { | |||
envp.dump(dos); | |||
} | |||
} |
@@ -55,8 +55,8 @@ public class ArrayElementValue extends ElementValue { | |||
public void dump(DataOutputStream dos) throws IOException { | |||
dos.writeByte(type); // u1 type of value (ARRAY == '[') | |||
dos.writeShort(evalues.length); | |||
for (int i = 0; i < evalues.length; i++) { | |||
evalues[i].dump(dos); | |||
for (ElementValue evalue : evalues) { | |||
evalue.dump(dos); | |||
} | |||
} | |||
@@ -64,8 +64,7 @@ public abstract class RuntimeAnnos extends Attribute { | |||
dos.write(annotation_data, 0, length); | |||
} else { | |||
dos.writeShort(annotations.size()); | |||
for (Iterator<AnnotationGen> i = annotations.iterator(); i.hasNext();) { | |||
AnnotationGen ann = i.next(); | |||
for (AnnotationGen ann : annotations) { | |||
ann.dump(dos); | |||
} | |||
} |
@@ -115,11 +115,10 @@ public abstract class RuntimeParamAnnos extends Attribute { | |||
dos.write(annotation_data,0,length); | |||
} else { | |||
dos.writeByte(parameterAnnotations.size()); | |||
for (int i=0; i<parameterAnnotations.size(); i++) { | |||
AnnotationGen[] annotations = parameterAnnotations.get(i); | |||
for (AnnotationGen[] annotations : parameterAnnotations) { | |||
dos.writeShort(annotations.length); | |||
for (int j=0; j<annotations.length;j++) { | |||
annotations[j].dump(dos); | |||
for (AnnotationGen annotation : annotations) { | |||
annotation.dump(dos); | |||
} | |||
} | |||
} |
@@ -47,8 +47,8 @@ public abstract class RuntimeTypeAnnos extends Attribute { | |||
dos.write(annotation_data,0,length); | |||
} else { | |||
dos.writeShort(typeAnnotations.length); | |||
for (int i=0; i<typeAnnotations.length; i++) { | |||
typeAnnotations[i].dump(dos); | |||
for (TypeAnnotationGen typeAnnotation : typeAnnotations) { | |||
typeAnnotation.dump(dos); | |||
} | |||
} | |||
} |
@@ -182,8 +182,8 @@ public class TypeAnnotationGen { | |||
case LOCAL_VARIABLE: | |||
case RESOURCE_VARIABLE: | |||
dos.writeShort(localVarTarget.length/3); | |||
for (int i=0;i<localVarTarget.length;i++) { | |||
dos.writeShort(localVarTarget[i]); | |||
for (int j : localVarTarget) { | |||
dos.writeShort(j); | |||
} | |||
break; | |||
case EXCEPTION_PARAMETER: | |||
@@ -208,8 +208,8 @@ public class TypeAnnotationGen { | |||
throw new IllegalStateException("nyi "+targetType); | |||
} | |||
dos.writeByte(typePath.length); | |||
for (int i=0;i<typePath.length;i++) { | |||
dos.writeByte(typePath[i]); | |||
for (int j : typePath) { | |||
dos.writeByte(j); | |||
} | |||
annotation.dump(dos); | |||
} |
@@ -141,8 +141,8 @@ public class ClassGen extends Modifiers implements Cloneable { | |||
Field[] fields = clazz.getFields(); | |||
String[] interfaces = clazz.getInterfaceNames(); | |||
for (int i = 0; i < interfaces.length; i++) { | |||
addInterface(interfaces[i]); | |||
for (String anInterface : interfaces) { | |||
addInterface(anInterface); | |||
} | |||
// OPTIMIZE Could make unpacking lazy, done on first reference | |||
@@ -165,12 +165,12 @@ public class ClassGen extends Modifiers implements Cloneable { | |||
} | |||
} | |||
for (int i = 0; i < methods.length; i++) { | |||
addMethod(methods[i]); | |||
for (Method method : methods) { | |||
addMethod(method); | |||
} | |||
for (int i = 0; i < fields.length; i++) { | |||
addField(fields[i]); | |||
for (Field field : fields) { | |||
addField(field); | |||
} | |||
} | |||
@@ -367,14 +367,12 @@ public class ClassGen extends Modifiers implements Cloneable { | |||
public void setMethods(Method[] methods) { | |||
methodsList.clear(); | |||
for (int m = 0; m < methods.length; m++) | |||
addMethod(methods[m]); | |||
for (Method method : methods) addMethod(method); | |||
} | |||
public void setFields(Field[] fs) { | |||
fieldsList.clear(); | |||
for (int m = 0; m < fs.length; m++) | |||
addField(fs[m]); | |||
for (Field f : fs) addField(f); | |||
} | |||
public void setMethodAt(Method method, int pos) { | |||
@@ -498,8 +496,7 @@ public class ClassGen extends Modifiers implements Cloneable { | |||
String[] names = getInterfaceNames(); | |||
if (names != null) { | |||
Arrays.sort(names); | |||
for (int i = 0; i < names.length; i++) | |||
dos.writeUTF(names[i]); | |||
for (String name : names) dos.writeUTF(name); | |||
} | |||
// 4. ordered list of fields (ignoring private static and private transient fields): |
@@ -111,18 +111,17 @@ public class FieldGen extends FieldGenOrMethodGen { | |||
Attribute[] attrs = field.getAttributes(); | |||
for (int i = 0; i < attrs.length; i++) { | |||
if (attrs[i] instanceof ConstantValue) { | |||
setValue(((ConstantValue) attrs[i]).getConstantValueIndex()); | |||
} else if (attrs[i] instanceof RuntimeAnnos) { | |||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attrs[i]; | |||
for (Attribute attr : attrs) { | |||
if (attr instanceof ConstantValue) { | |||
setValue(((ConstantValue) attr).getConstantValueIndex()); | |||
} else if (attr instanceof RuntimeAnnos) { | |||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attr; | |||
List<AnnotationGen> l = runtimeAnnotations.getAnnotations(); | |||
for (Iterator<AnnotationGen> it = l.iterator(); it.hasNext();) { | |||
AnnotationGen element = it.next(); | |||
for (AnnotationGen element : l) { | |||
addAnnotation(new AnnotationGen(element, cp, false)); | |||
} | |||
} else { | |||
addAttribute(attrs[i]); | |||
addAttribute(attr); | |||
} | |||
} | |||
} |
@@ -119,8 +119,8 @@ public class InstructionFactory implements InstructionConstants { | |||
return new InvokeInstruction(Constants.INVOKESTATIC, index); | |||
case Constants.INVOKEINTERFACE: | |||
int nargs = 0; | |||
for (int i = 0; i < arg_types.length; i++) { | |||
nargs += arg_types[i].getSize(); | |||
for (Type arg_type : arg_types) { | |||
nargs += arg_type.getSize(); | |||
} | |||
return new INVOKEINTERFACE(index, nargs + 1, 0); | |||
default: | |||
@@ -148,8 +148,8 @@ public class InstructionFactory implements InstructionConstants { | |||
case Constants.INVOKEINTERFACE: | |||
Type[] argumentTypes = Type.getArgumentTypes(signature); | |||
int nargs = 0; | |||
for (int i = 0; i < argumentTypes.length; i++) {// Count size of arguments | |||
nargs += argumentTypes[i].getSize(); | |||
for (Type argumentType : argumentTypes) {// Count size of arguments | |||
nargs += argumentType.getSize(); | |||
} | |||
return new INVOKEINTERFACE(index, nargs + 1, 0); | |||
default: |
@@ -953,8 +953,8 @@ public class InstructionList implements Serializable { | |||
if (i instanceof InstructionSelect) { | |||
InstructionHandle[] targets = ((InstructionSelect) i).getTargets(); | |||
for (int j = 0; j < targets.length; j++) { | |||
inst = targets[j].instruction; | |||
for (InstructionHandle target : targets) { | |||
inst = target.instruction; | |||
if (!contains(inst)) { | |||
throw new ClassGenException("Branch target of " + Constants.OPCODE_NAMES[i.opcode] + ":" + inst | |||
+ " not in instruction list"); | |||
@@ -1247,15 +1247,15 @@ public class InstructionList implements Serializable { | |||
* @see MethodGen | |||
*/ | |||
public void redirectLocalVariables(LocalVariableGen[] lg, InstructionHandle old_target, InstructionHandle new_target) { | |||
for (int i = 0; i < lg.length; i++) { | |||
InstructionHandle start = lg[i].getStart(); | |||
InstructionHandle end = lg[i].getEnd(); | |||
for (LocalVariableGen localVariableGen : lg) { | |||
InstructionHandle start = localVariableGen.getStart(); | |||
InstructionHandle end = localVariableGen.getEnd(); | |||
if (start == old_target) { | |||
lg[i].setStart(new_target); | |||
localVariableGen.setStart(new_target); | |||
} | |||
if (end == old_target) { | |||
lg[i].setEnd(new_target); | |||
localVariableGen.setEnd(new_target); | |||
} | |||
} | |||
} | |||
@@ -1269,17 +1269,17 @@ public class InstructionList implements Serializable { | |||
* @see MethodGen | |||
*/ | |||
public void redirectExceptionHandlers(CodeExceptionGen[] exceptions, InstructionHandle old_target, InstructionHandle new_target) { | |||
for (int i = 0; i < exceptions.length; i++) { | |||
if (exceptions[i].getStartPC() == old_target) { | |||
exceptions[i].setStartPC(new_target); | |||
for (CodeExceptionGen exception : exceptions) { | |||
if (exception.getStartPC() == old_target) { | |||
exception.setStartPC(new_target); | |||
} | |||
if (exceptions[i].getEndPC() == old_target) { | |||
exceptions[i].setEndPC(new_target); | |||
if (exception.getEndPC() == old_target) { | |||
exception.setEndPC(new_target); | |||
} | |||
if (exceptions[i].getHandlerPC() == old_target) { | |||
exceptions[i].setHandlerPC(new_target); | |||
if (exception.getHandlerPC() == old_target) { | |||
exception.setHandlerPC(new_target); | |||
} | |||
} | |||
} |
@@ -88,8 +88,8 @@ public abstract class InstructionSelect extends InstructionBranch { | |||
super(opcode, target); | |||
this.targets = targets; | |||
for (int i = 0; i < targets.length; i++) { | |||
notifyTarget(null, targets[i], this); | |||
for (InstructionHandle instructionHandle : targets) { | |||
notifyTarget(null, instructionHandle, this); | |||
} | |||
this.match = match; | |||
@@ -236,8 +236,8 @@ public abstract class InstructionSelect extends InstructionBranch { | |||
return true; | |||
} | |||
for (int i = 0; i < targets.length; i++) { | |||
if (targets[i] == ih) { | |||
for (InstructionHandle target : targets) { | |||
if (target == ih) { | |||
return true; | |||
} | |||
} | |||
@@ -251,8 +251,8 @@ public abstract class InstructionSelect extends InstructionBranch { | |||
void dispose() { | |||
super.dispose(); | |||
for (int i = 0; i < targets.length; i++) { | |||
targets[i].removeTargeter(this); | |||
for (InstructionHandle target : targets) { | |||
target.removeTargeter(this); | |||
} | |||
} | |||
@@ -212,8 +212,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
.getCode()) : null, cp); | |||
Attribute[] attributes = m.getAttributes(); | |||
for (int i = 0; i < attributes.length; i++) { | |||
Attribute a = attributes[i]; | |||
for (Attribute attribute : attributes) { | |||
Attribute a = attribute; | |||
if (a instanceof Code) { | |||
Code code = (Code) a; | |||
@@ -254,15 +254,14 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
} | |||
Attribute[] codeAttrs = code.getAttributes(); | |||
for (int j = 0; j < codeAttrs.length; j++) { | |||
a = codeAttrs[j]; | |||
for (Attribute codeAttr : codeAttrs) { | |||
a = codeAttr; | |||
if (a instanceof LineNumberTable) { | |||
LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable(); | |||
if (useTags) { | |||
// abracadabra, lets create tags rather than linenumbergens. | |||
for (int k = 0; k < ln.length; k++) { | |||
LineNumber l = ln[k]; | |||
for (LineNumber l : ln) { | |||
int lnum = l.getLineNumber(); | |||
if (lnum > highestLineNumber) { | |||
highestLineNumber = lnum; | |||
@@ -271,8 +270,7 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
il.findHandle(l.getStartPC(), arrayOfInstructions, true).addTargeter(lt); | |||
} | |||
} else { | |||
for (int k = 0; k < ln.length; k++) { | |||
LineNumber l = ln[k]; | |||
for (LineNumber l : ln) { | |||
addLineNumber(il.findHandle(l.getStartPC(), arrayOfInstructions, true), l.getLineNumber()); | |||
} | |||
} | |||
@@ -282,8 +280,7 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
if (useTags) { | |||
LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable(); | |||
for (int k = 0; k < lv.length; k++) { | |||
LocalVariable l = lv[k]; | |||
for (LocalVariable l : lv) { | |||
Type t = Type.getType(l.getSignature()); | |||
LocalVariableTag lvt = new LocalVariableTag(t, l.getSignature(), l.getName(), l.getIndex(), l | |||
.getStartPC()); | |||
@@ -307,8 +304,7 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
removeLocalVariables(); | |||
for (int k = 0; k < lv.length; k++) { | |||
LocalVariable l = lv[k]; | |||
for (LocalVariable l : lv) { | |||
InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions); | |||
InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength(), arrayOfInstructions); | |||
// AMC, this actually gives us the first instruction AFTER the range, | |||
@@ -333,8 +329,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
} | |||
} else if (a instanceof ExceptionTable) { | |||
String[] names = ((ExceptionTable) a).getExceptionNames(); | |||
for (int j = 0; j < names.length; j++) { | |||
addException(names[j]); | |||
for (String s : names) { | |||
addException(s); | |||
} | |||
} else if (a instanceof RuntimeAnnos) { | |||
RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) a; | |||
@@ -647,8 +643,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
} | |||
Attribute[] attrs = Utility.getParameterAnnotationAttributes(cp, param_annotations); | |||
if (attrs != null) { | |||
for (int i = 0; i < attrs.length; i++) { | |||
addAttribute(attrs[i]); | |||
for (Attribute attr : attrs) { | |||
addAttribute(attr); | |||
} | |||
} | |||
} | |||
@@ -722,8 +718,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
* Each attribute causes 6 additional header bytes | |||
*/ | |||
int attrs_len = 0; | |||
for (int i = 0; i < code_attrs.length; i++) { | |||
attrs_len += (code_attrs[i].getLength() + 6); | |||
for (Attribute code_attr : code_attrs) { | |||
attrs_len += (code_attr.getLength() + 6); | |||
} | |||
CodeException[] c_exc = getCodeExceptions(); | |||
@@ -734,8 +730,7 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
if ((il != null) && !isAbstract()) { | |||
// Remove any stale code attribute | |||
List<Attribute> attributes = getAttributes(); | |||
for (int i = 0; i < attributes.size(); i++) { | |||
Attribute a = attributes.get(i); | |||
for (Attribute a : attributes) { | |||
if (a instanceof Code) { | |||
removeAttribute(a); | |||
} | |||
@@ -897,8 +892,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
int max = isStatic() ? 0 : 1; | |||
if (parameterTypes != null) { | |||
for (int i = 0; i < parameterTypes.length; i++) { | |||
max += parameterTypes[i].getSize(); | |||
for (Type parameterType : parameterTypes) { | |||
max += parameterType.getSize(); | |||
} | |||
} | |||
@@ -985,8 +980,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
* Initially, populate the branch stack with the exception handlers, because these aren't (necessarily) branched to | |||
* explicitly. In each case, the stack will have depth 1, containing the exception object. | |||
*/ | |||
for (int i = 0, max = et.length; i < max; i++) { | |||
InstructionHandle handlerPos = et[i].getHandlerPC(); | |||
for (CodeExceptionGen codeExceptionGen : et) { | |||
InstructionHandle handlerPos = codeExceptionGen.getHandlerPC(); | |||
if (handlerPos != null) { | |||
// it must be at least 1 since there is an exception handler | |||
maxStackDepth = 1; | |||
@@ -1014,8 +1009,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
// explore all of the select's targets. the default target is handled below. | |||
InstructionSelect select = (InstructionSelect) branch; | |||
InstructionHandle[] targets = select.getTargets(); | |||
for (int i = 0; i < targets.length; i++) { | |||
branchTargets.push(targets[i], stackDepth); | |||
for (InstructionHandle target : targets) { | |||
branchTargets.push(target, stackDepth); | |||
} | |||
// nothing to fall through to. | |||
ih = null; | |||
@@ -1069,8 +1064,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
StringBuffer buf = new StringBuffer(signature); | |||
if (exceptionsThrown.size() > 0) { | |||
for (Iterator<String> e = exceptionsThrown.iterator(); e.hasNext();) { | |||
buf.append("\n\t\tthrows " + e.next()); | |||
for (String s : exceptionsThrown) { | |||
buf.append("\n\t\tthrows " + s); | |||
} | |||
} | |||
@@ -1145,8 +1140,8 @@ public class MethodGen extends FieldGenOrMethodGen { | |||
private List /* AnnotationGen */<AnnotationGen> makeMutableVersion(AnnotationGen[] mutableArray) { | |||
List<AnnotationGen> result = new ArrayList<AnnotationGen>(); | |||
for (int i = 0; i < mutableArray.length; i++) { | |||
result.add(new AnnotationGen(mutableArray[i], getConstantPool(), false)); | |||
for (AnnotationGen annotationGen : mutableArray) { | |||
result.add(new AnnotationGen(annotationGen, getConstantPool(), false)); | |||
} | |||
return result; | |||
} |
@@ -280,10 +280,10 @@ public abstract class ReferenceType extends Type { | |||
this_sups[0] = Repository.lookupClass(thiz.getClassName()); | |||
t_sups[0] = Repository.lookupClass(other.getClassName()); | |||
for (int i = 0; i < t_sups.length; i++) { | |||
for (int j = 0; j < this_sups.length; j++) { | |||
if (this_sups[j].equals(t_sups[i])) { | |||
return new ObjectType(this_sups[j].getClassName()); | |||
for (JavaClass t_sup : t_sups) { | |||
for (JavaClass this_sup : this_sups) { | |||
if (this_sup.equals(t_sup)) { | |||
return new ObjectType(this_sup.getClassName()); | |||
} | |||
} | |||
} |
@@ -466,8 +466,8 @@ public abstract class Type { | |||
StringBuffer sb = new StringBuffer("("); | |||
Class[] params = meth.getParameterTypes(); // avoid clone | |||
for (int j = 0; j < params.length; j++) { | |||
sb.append(getType(params[j]).getSignature()); | |||
for (Class param : params) { | |||
sb.append(getType(param).getSignature()); | |||
} | |||
sb.append(")"); | |||
@@ -479,8 +479,8 @@ public abstract class Type { | |||
StringBuffer sb = new StringBuffer("("); | |||
Class<?>[] params = cons.getParameterTypes(); // avoid clone | |||
for (int j = 0; j < params.length; j++) { | |||
sb.append(getType(params[j]).getSignature()); | |||
for (Class<?> param : params) { | |||
sb.append(getType(param).getSignature()); | |||
} | |||
sb.append(")V"); |
@@ -148,8 +148,7 @@ public class NonCachingClassLoaderRepository implements Repository { | |||
public void clear() { | |||
processQueue(); | |||
Set<Object> keys = map.keySet(); | |||
for (Iterator<Object> iterator = keys.iterator(); iterator.hasNext();) { | |||
Object name = iterator.next(); | |||
for (Object name : keys) { | |||
map.remove(name); | |||
} | |||
} |
@@ -54,8 +54,7 @@ public abstract class BcelTestCase extends TestCase { | |||
protected Method getMethod(JavaClass cl, String methodname) { | |||
Method[] methods = cl.getMethods(); | |||
for (int i = 0; i < methods.length; i++) { | |||
Method m = methods[i]; | |||
for (Method m : methods) { | |||
if (m.getName().equals(methodname)) { | |||
return m; | |||
} | |||
@@ -65,8 +64,7 @@ public abstract class BcelTestCase extends TestCase { | |||
protected Field getField(JavaClass cl, String fieldname) { | |||
Field[] fields = cl.getFields(); | |||
for (int i = 0; i < fields.length; i++) { | |||
Field f = fields[i]; | |||
for (Field f : fields) { | |||
if (f.getName().equals(fieldname)) { | |||
return f; | |||
} | |||
@@ -96,22 +94,22 @@ public abstract class BcelTestCase extends TestCase { | |||
protected Attribute[] findAttribute(String name, JavaClass clazz) { | |||
Attribute[] all = clazz.getAttributes(); | |||
List<Attribute> chosenAttrsList = new ArrayList<Attribute>(); | |||
for (int i = 0; i < all.length; i++) { | |||
for (Attribute attribute : all) { | |||
if (verbose) | |||
System.err.println("Attribute: " + all[i].getName()); | |||
if (all[i].getName().equals(name)) | |||
chosenAttrsList.add(all[i]); | |||
System.err.println("Attribute: " + attribute.getName()); | |||
if (attribute.getName().equals(name)) | |||
chosenAttrsList.add(attribute); | |||
} | |||
return chosenAttrsList.toArray(new Attribute[] {}); | |||
} | |||
protected Attribute findAttribute(String name, Attribute[] all) { | |||
List<Attribute> chosenAttrsList = new ArrayList<Attribute>(); | |||
for (int i = 0; i < all.length; i++) { | |||
for (Attribute attribute : all) { | |||
if (verbose) | |||
System.err.println("Attribute: " + all[i].getName()); | |||
if (all[i].getName().equals(name)) | |||
chosenAttrsList.add(all[i]); | |||
System.err.println("Attribute: " + attribute.getName()); | |||
if (attribute.getName().equals(name)) | |||
chosenAttrsList.add(attribute); | |||
} | |||
assertTrue("Should be one match: " + chosenAttrsList.size(), chosenAttrsList.size() == 1); | |||
return chosenAttrsList.get(0); |
@@ -102,12 +102,11 @@ public class FieldAnnotationsTest extends BcelTestCase { | |||
String annotationName,String annotationElementName,String annotationElementValue) { | |||
Field[] fields = clazz.getFields(); | |||
for (int i = 0; i < fields.length; i++) { | |||
Field f = fields[i]; | |||
for (Field f : fields) { | |||
AnnotationGen[] fieldAnnotations = f.getAnnotations(); | |||
if (f.getName().equals(fieldname)) { | |||
checkAnnotation(fieldAnnotations[0],annotationName,annotationElementName,annotationElementValue); | |||
checkAnnotation(fieldAnnotations[0], annotationName, annotationElementName, annotationElementValue); | |||
} | |||
} | |||
} | |||
@@ -127,11 +126,10 @@ public class FieldAnnotationsTest extends BcelTestCase { | |||
// helper methods | |||
public void checkValue(AnnotationGen a,String name,String tostring) { | |||
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) { | |||
NameValuePair element = i.next(); | |||
for (NameValuePair element : a.getValues()) { | |||
if (element.getNameString().equals(name)) { | |||
if (!element.getValue().stringifyValue().equals(tostring)) { | |||
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); | |||
fail("Expected element " + name + " to have value " + tostring + " but it had value " + element.getValue().stringifyValue()); | |||
} | |||
return; | |||
} |
@@ -240,8 +240,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { | |||
assertTrue("Expected one annotation but found " + annotations.length, annotations.length == 1); | |||
List<NameValuePair> l = annotations[0].getValues(); | |||
boolean found = false; | |||
for (Iterator<NameValuePair> iter = l.iterator(); iter.hasNext();) { | |||
NameValuePair element = iter.next(); | |||
for (NameValuePair element : l) { | |||
if (element.getNameString().equals("dval")) { | |||
if (((SimpleElementValue) element.getValue()).stringifyValue().equals("33.4")) | |||
found = true; |
@@ -187,10 +187,9 @@ public class GenericSignatureParsingTest extends BcelTestCase { | |||
public Signature getSignatureAttribute(JavaClass clazz,String name) { | |||
Method m = getMethod(clazz,name); | |||
Attribute[] as = m.getAttributes(); | |||
for (int i = 0; i < as.length; i++) { | |||
Attribute attribute = as[i]; | |||
for (Attribute attribute : as) { | |||
if (attribute.getName().equals("Signature")) { | |||
return (Signature)attribute; | |||
return (Signature) attribute; | |||
} | |||
} | |||
return null; | |||
@@ -292,23 +291,23 @@ public class GenericSignatureParsingTest extends BcelTestCase { | |||
char[] chars = brackets.toCharArray(); | |||
int count = 0; | |||
boolean open = false; | |||
for(int i=0; i<chars.length; i++) { | |||
switch(chars[i]) { | |||
case '[': | |||
if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); | |||
open = true; | |||
break; | |||
case ']': | |||
if (!open) throw new RuntimeException("Illegally nested brackets:" + brackets); | |||
open = false; | |||
count++; | |||
break; | |||
default: | |||
} | |||
} | |||
for (char aChar : chars) { | |||
switch (aChar) { | |||
case '[': | |||
if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); | |||
open = true; | |||
break; | |||
case ']': | |||
if (!open) throw new RuntimeException("Illegally nested brackets:" + brackets); | |||
open = false; | |||
count++; | |||
break; | |||
default: | |||
} | |||
} | |||
if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); | |||
@@ -454,14 +453,14 @@ public class GenericSignatureParsingTest extends BcelTestCase { | |||
StringBuffer buf = new StringBuffer("("); | |||
if (methodArgs != null) { | |||
for (int i=0; i < methodArgs.length; i++) { | |||
String str = GenericSignatureParsingTest.getSignature(methodArgs[i]); | |||
if (str.equals("V")) // void can't be a method argument | |||
throw new ClassFormatException("Invalid type: " + methodArgs[i]); | |||
buf.append(str); | |||
} | |||
for (String methodArg : methodArgs) { | |||
String str = GenericSignatureParsingTest.getSignature(methodArg); | |||
if (str.equals("V")) // void can't be a method argument | |||
throw new ClassFormatException("Invalid type: " + methodArg); | |||
buf.append(str); | |||
} | |||
} | |||
buf.append(")" + GenericSignatureParsingTest.getSignature(returnType)); |
@@ -38,10 +38,9 @@ public class GenericsErasureTesting extends BcelTestCase { | |||
public Signature getSignatureAttribute(JavaClass clazz,String name) { | |||
Method m = getMethod(clazz,name); | |||
Attribute[] as = m.getAttributes(); | |||
for (int i = 0; i < as.length; i++) { | |||
Attribute attribute = as[i]; | |||
for (Attribute attribute : as) { | |||
if (attribute.getName().equals("Signature")) { | |||
return (Signature)attribute; | |||
return (Signature) attribute; | |||
} | |||
} | |||
return null; |
@@ -45,18 +45,18 @@ public class LocalVariableTypeTableTest extends BcelTestCase { | |||
boolean tc1OK = false; | |||
boolean tc2OK = false; | |||
String errormessage = null; | |||
for (int i = 0; i < lvtable.length; i++) { | |||
String sig = Utility.signatureToString(lvtable[i].getSignature()); | |||
if (lvtable[i].getName().equals("tc1")) { | |||
for (LocalVariable localVariable : lvtable) { | |||
String sig = Utility.signatureToString(localVariable.getSignature()); | |||
if (localVariable.getName().equals("tc1")) { | |||
if (!sig.equals("TreasureChest<String>")) { | |||
errormessage="Expected signature of 'TreasureChest<String>' for tc1 but got "+sig; | |||
errormessage = "Expected signature of 'TreasureChest<String>' for tc1 but got " + sig; | |||
} else { | |||
tc1OK = true; | |||
} | |||
} | |||
if (lvtable[i].getName().equals("tc2")) { | |||
if (localVariable.getName().equals("tc2")) { | |||
if (!sig.equals("TreasureChest<Integer>")) { | |||
errormessage="Expected signature of 'TreasureChest<Integer>' for tc2 but got "+sig; | |||
errormessage = "Expected signature of 'TreasureChest<Integer>' for tc2 but got " + sig; | |||
} else { | |||
tc2OK = true; | |||
} |
@@ -63,12 +63,11 @@ public class MethodAnnotationsTest extends BcelTestCase { | |||
String annotationName,String annotationElementName,String annotationElementValue) { | |||
Method[] methods = clazz.getMethods(); | |||
for (int i = 0; i < methods.length; i++) { | |||
Method m = methods[i]; | |||
for (Method m : methods) { | |||
AnnotationGen[] methodAnnotations = m.getAnnotations(); | |||
if (m.getName().equals(methodname)) { | |||
checkAnnotation(methodAnnotations[0],annotationName,annotationElementName,annotationElementValue); | |||
checkAnnotation(methodAnnotations[0], annotationName, annotationElementName, annotationElementValue); | |||
} | |||
} | |||
} | |||
@@ -88,11 +87,10 @@ public class MethodAnnotationsTest extends BcelTestCase { | |||
// helper methods | |||
public void checkValue(AnnotationGen a,String name,String tostring) { | |||
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) { | |||
NameValuePair element = i.next(); | |||
for (NameValuePair element : a.getValues()) { | |||
if (element.getNameString().equals(name)) { | |||
if (!element.getValue().stringifyValue().equals(tostring)) { | |||
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); | |||
fail("Expected element " + name + " to have value " + tostring + " but it had value " + element.getValue().stringifyValue()); | |||
} | |||
return; | |||
} |
@@ -271,8 +271,8 @@ public class ParameterAnnotationsTest extends BcelTestCase { | |||
private Method findMethod(ClassGen c,String mname) { | |||
Method[] ms = c.getMethods(); | |||
for (int i = 0; i < ms.length; i++) { | |||
if (ms[i].getName().equals(mname)) return ms[i]; | |||
for (Method m : ms) { | |||
if (m.getName().equals(mname)) return m; | |||
} | |||
return null; | |||
} |
@@ -208,11 +208,10 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { | |||
} | |||
private void checkValue(AnnotationGen a,String name,String tostring) { | |||
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) { | |||
NameValuePair element = i.next(); | |||
for (NameValuePair element : a.getValues()) { | |||
if (element.getNameString().equals(name)) { | |||
if (!element.getValue().stringifyValue().equals(tostring)) { | |||
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); | |||
fail("Expected element " + name + " to have value " + tostring + " but it had value " + element.getValue().stringifyValue()); | |||
} | |||
return; | |||
} | |||
@@ -385,8 +384,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { | |||
public static List<String> getListOfAnnotationNames(AnnotationGen a) { | |||
List<NameValuePair> l = a.getValues(); | |||
List<String> names = new ArrayList<String>(); | |||
for (Iterator<NameValuePair> i = l.iterator(); i.hasNext();) { | |||
NameValuePair element = i.next(); | |||
for (NameValuePair element : l) { | |||
names.add(element.getNameString()); | |||
} | |||
return names; |
@@ -38,30 +38,29 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase | |||
Attribute[] rvaAttr = findAttribute("RuntimeVisibleParameterAnnotations",clazz); | |||
Method[] methods = clazz.getMethods(); | |||
for (int i = 0; i < methods.length; i++) { | |||
Method m = methods[i]; | |||
for (Method m : methods) { | |||
if (m.getName().equals("foo")) { | |||
RuntimeVisParamAnnos paramAnns = | |||
(RuntimeVisParamAnnos) findAttribute("RuntimeVisibleParameterAnnotations",m.getAttributes()); | |||
assertTrue("foo takes two parameters, not "+paramAnns.getParameterAnnotations().size(), | |||
paramAnns.getParameterAnnotations().size()==2); | |||
RuntimeVisParamAnnos paramAnns = | |||
(RuntimeVisParamAnnos) findAttribute("RuntimeVisibleParameterAnnotations", m.getAttributes()); | |||
assertTrue("foo takes two parameters, not " + paramAnns.getParameterAnnotations().size(), | |||
paramAnns.getParameterAnnotations().size() == 2); | |||
AnnotationGen[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0); | |||
checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","2"); | |||
checkAnnotation(firstParamAnnotations[0], "SimpleAnnotation", "id", "2"); | |||
AnnotationGen[] secondParamAnnotations = paramAnns.getAnnotationsOnParameter(1); | |||
checkAnnotation(secondParamAnnotations[0],"SimpleAnnotation","id","3"); | |||
checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","LSimpleEnum;Red"); | |||
checkAnnotation(secondParamAnnotations[0], "SimpleAnnotation", "id", "3"); | |||
checkAnnotation(secondParamAnnotations[1], "AnnotationEnumElement", "enumval", "LSimpleEnum;Red"); | |||
} | |||
if (m.getName().equals("main")) { | |||
RuntimeVisParamAnnos paramAnns = | |||
(RuntimeVisParamAnnos) findAttribute("RuntimeVisibleParameterAnnotations",m.getAttributes()); | |||
assertTrue("main takes one parameter, not "+paramAnns.getParameterAnnotations().size(), | |||
paramAnns.getParameterAnnotations().size()==1); | |||
RuntimeVisParamAnnos paramAnns = | |||
(RuntimeVisParamAnnos) findAttribute("RuntimeVisibleParameterAnnotations", m.getAttributes()); | |||
assertTrue("main takes one parameter, not " + paramAnns.getParameterAnnotations().size(), | |||
paramAnns.getParameterAnnotations().size() == 1); | |||
AnnotationGen[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0); | |||
checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","1"); | |||
checkAnnotation(firstParamAnnotations[0], "SimpleAnnotation", "id", "1"); | |||
} | |||
} | |||
} | |||
@@ -94,17 +93,16 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase | |||
public void checkFooMethod(JavaClass clazz) { | |||
Method[] methods = clazz.getMethods(); | |||
for (int i = 0; i < methods.length; i++) { | |||
Method m = methods[i]; | |||
for (Method m : methods) { | |||
if (m.getName().equals("foo")) { | |||
AnnotationGen[] firstParamAnnotations = m.getAnnotationsOnParameter(0); | |||
checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","2"); | |||
checkAnnotation(firstParamAnnotations[0], "SimpleAnnotation", "id", "2"); | |||
AnnotationGen[] secondParamAnnotations = m.getAnnotationsOnParameter(1); | |||
checkAnnotation(secondParamAnnotations[0],"SimpleAnnotation","id","3"); | |||
checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","LSimpleEnum;Red"); | |||
checkAnnotation(secondParamAnnotations[0], "SimpleAnnotation", "id", "3"); | |||
checkAnnotation(secondParamAnnotations[1], "AnnotationEnumElement", "enumval", "LSimpleEnum;Red"); | |||
} | |||
} | |||
} | |||
@@ -124,11 +122,10 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase | |||
// helper methods | |||
public void checkValue(AnnotationGen a,String name,String tostring) { | |||
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) { | |||
NameValuePair element = i.next(); | |||
for (NameValuePair element : a.getValues()) { | |||
if (element.getNameString().equals(name)) { | |||
if (!element.getValue().stringifyValue().equals(tostring)) { | |||
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); | |||
fail("Expected element " + name + " to have value " + tostring + " but it had value " + element.getValue().stringifyValue()); | |||
} | |||
return; | |||
} |
@@ -65,11 +65,10 @@ public class VarargsTest extends BcelTestCase { | |||
public void checkMarkedVarargs(JavaClass clazz,String methodname,boolean shouldBeMarked) { | |||
Method[] methods = clazz.getMethods(); | |||
for (int i = 0; i < methods.length; i++) { | |||
Method m = methods[i]; | |||
for (Method m : methods) { | |||
if (m.getName().equals(methodname)) { | |||
assertTrue("Method '"+methodname+"' should answer varargs="+shouldBeMarked, | |||
m.isVarargs()==shouldBeMarked); | |||
assertTrue("Method '" + methodname + "' should answer varargs=" + shouldBeMarked, | |||
m.isVarargs() == shouldBeMarked); | |||
} | |||
} | |||
} | |||
@@ -78,11 +77,10 @@ public class VarargsTest extends BcelTestCase { | |||
// helper methods | |||
public void checkValue(AnnotationGen a,String name,String tostring) { | |||
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) { | |||
NameValuePair element = i.next(); | |||
for (NameValuePair element : a.getValues()) { | |||
if (element.getNameString().equals(name)) { | |||
if (!element.getValue().stringifyValue().equals(tostring)) { | |||
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); | |||
fail("Expected element " + name + " to have value " + tostring + " but it had value " + element.getValue().stringifyValue()); | |||
} | |||
return; | |||
} |
@@ -1101,8 +1101,8 @@ public class MessageUtil { | |||
return true; | |||
} | |||
boolean result = true; | |||
for (int i = 0; i < sources.length; i++) { | |||
if (!sink.handleMessage(sources[i])) { | |||
for (IMessage source : sources) { | |||
if (!sink.handleMessage(source)) { | |||
if (fastFail) { | |||
return false; | |||
} |
@@ -74,18 +74,18 @@ public class MessageTest extends TestCase { | |||
public void testKind_isSameOrLessThan() { | |||
IMessage.Kind last; | |||
IMessage.Kind next = null; | |||
for (Iterator<IMessage.Kind> iter = IMessage.KINDS.iterator(); iter.hasNext();) { | |||
last = next; | |||
next = iter.next(); | |||
if (null == last) { | |||
continue; | |||
} | |||
String label = "last: " + last + " next: " + next; | |||
assertTrue(label, !next.isSameOrLessThan(null)); | |||
assertTrue(label, !next.isSameOrLessThan(last)); | |||
assertTrue(label, last.isSameOrLessThan(next)); | |||
assertTrue(label, next.isSameOrLessThan(next)); | |||
} | |||
for (IMessage.Kind kind : IMessage.KINDS) { | |||
last = next; | |||
next = kind; | |||
if (null == last) { | |||
continue; | |||
} | |||
String label = "last: " + last + " next: " + next; | |||
assertTrue(label, !next.isSameOrLessThan(null)); | |||
assertTrue(label, !next.isSameOrLessThan(last)); | |||
assertTrue(label, last.isSameOrLessThan(next)); | |||
assertTrue(label, next.isSameOrLessThan(next)); | |||
} | |||
} | |||
public void testMessageHandler() { |
@@ -707,8 +707,8 @@ class InstallContext { | |||
public boolean isTextFile(File file) { | |||
String name = file.getName(); | |||
for (int i = 0; i < TEXT_EXTENSIONS.length; i++) { | |||
if (name.endsWith(TEXT_EXTENSIONS[i])) { | |||
for (String textExtension : TEXT_EXTENSIONS) { | |||
if (name.endsWith(textExtension)) { | |||
return true; | |||
} | |||
} | |||
@@ -1243,10 +1243,9 @@ class ConfigureLauncherPane extends WizardPane { | |||
paths = unixPaths; | |||
} | |||
for (int suffixIndex = 0; suffixIndex < suffixes.length; suffixIndex++) { | |||
String suffix = suffixes[suffixIndex]; | |||
for (int prefixIndex = 0; prefixIndex < paths.length; prefixIndex++) { | |||
String prefix = paths[prefixIndex]; | |||
for (String suffix : suffixes) { | |||
for (String path : paths) { | |||
String prefix = path; | |||
prefix = applyProperties(prefix); | |||
File test = new File(prefix + suffix); | |||
if (isLegalJavaHome(test)) { |
@@ -152,11 +152,10 @@ public class AJInstaller extends MatchingTask { | |||
StringBuffer buf = new StringBuffer(); | |||
buf.append(contentsBytes); | |||
buf.append(NEWLINE); | |||
for (Iterator<String> i = contentsNames.iterator(); i.hasNext(); ) { | |||
String name = i.next(); | |||
buf.append(name); | |||
buf.append(NEWLINE); | |||
} | |||
for (String name : contentsNames) { | |||
buf.append(name); | |||
buf.append(NEWLINE); | |||
} | |||
zipFile(new StringBufferInputStream(buf.toString()), zOut, CONTENTS_FILE, System.currentTimeMillis()); | |||
} | |||
@@ -347,19 +346,19 @@ public class AJInstaller extends MatchingTask { | |||
} | |||
protected void writeDirs(ZipOutputStream zOut, String[] dirs) throws IOException { | |||
for (int i = 0; i < dirs.length; i++) { | |||
File f = new File(baseDir,dirs[i]); | |||
String name = dirs[i].replace(File.separatorChar,'/')+"/"; | |||
zipDir(f, zOut, name); | |||
} | |||
for (String dir : dirs) { | |||
File f = new File(baseDir, dir); | |||
String name = dir.replace(File.separatorChar, '/') + "/"; | |||
zipDir(f, zOut, name); | |||
} | |||
} | |||
protected void writeFiles(ZipOutputStream zOut, String[] files) throws IOException { | |||
for (int i = 0; i < files.length; i++) { | |||
File f = new File(baseDir,files[i]); | |||
String name = files[i].replace(File.separatorChar,'/'); | |||
zipFile(f, zOut, name); | |||
} | |||
for (String file : files) { | |||
File f = new File(baseDir, file); | |||
String name = file.replace(File.separatorChar, '/'); | |||
zipFile(f, zOut, name); | |||
} | |||
} | |||
} |
@@ -95,8 +95,7 @@ public class AntBuilder extends Builder { | |||
Result[] reqs = result.getRequired(); | |||
StringBuffer depends = new StringBuffer(); | |||
boolean first = true; | |||
for (int i = 0; i < reqs.length; i++) { | |||
Result reqResult = reqs[i]; | |||
for (Result reqResult : reqs) { | |||
if (!first) { | |||
depends.append(","); | |||
} else { | |||
@@ -110,8 +109,7 @@ public class AntBuilder extends Builder { | |||
targets.put(resultTargetName, target); | |||
// then recursively add any required results | |||
for (int i = 0; i < reqs.length; i++) { | |||
Result reqResult = reqs[i]; | |||
for (Result reqResult : reqs) { | |||
makeTargetsForResult(reqResult, targets); | |||
} | |||
} | |||
@@ -311,8 +309,7 @@ public class AntBuilder extends Builder { | |||
public boolean setupClasspath(Result result, Path classpath) { // XXX fix test access | |||
boolean hasLibraries = false; | |||
// required libraries | |||
for (Iterator<File> iter = result.getLibJars().iterator(); iter.hasNext();) { | |||
File file = iter.next(); | |||
for (File file : result.getLibJars()) { | |||
classpath.createPathElement().setLocation(file); | |||
if (!hasLibraries) { | |||
hasLibraries = true; | |||
@@ -321,16 +318,15 @@ public class AntBuilder extends Builder { | |||
// Westodo Kind kind = result.getKind(); | |||
Result[] reqs = result.getRequired(); | |||
// required modules and their exported libraries | |||
for (int i = 0; i < reqs.length; i++) { | |||
Result requiredResult = reqs[i]; | |||
for (Result requiredResult : reqs) { | |||
classpath.createPathElement().setLocation(requiredResult.getOutputFile()); | |||
if (!hasLibraries) { | |||
hasLibraries = true; | |||
} | |||
// also put on classpath libraries exported from required module | |||
// XXX exported modules not supported | |||
for (Iterator<File> iterator = requiredResult.getExportedLibJars().iterator(); iterator.hasNext();) { | |||
classpath.createPathElement().setLocation(iterator.next()); | |||
for (File file : requiredResult.getExportedLibJars()) { | |||
classpath.createPathElement().setLocation(file); | |||
} | |||
} | |||
return hasLibraries; | |||
@@ -424,8 +420,7 @@ public class AntBuilder extends Builder { | |||
return new Result[0]; | |||
} | |||
ArrayList<String> toReturn = new ArrayList<String>(); | |||
for (Iterator<Target> iter = result.iterator(); iter.hasNext();) { | |||
Target target = iter.next(); | |||
for (Target target : result) { | |||
String name = target.getName(); | |||
if (null == name) { | |||
throw new Error("null name?"); |
@@ -145,11 +145,11 @@ public abstract class ConditionalTask extends Task { | |||
return isOneOf(prop, trues) || isOneOf(prop, complement(falses)); | |||
} | |||
private boolean isOneOf(String prop, String[] strings) { | |||
for (int i = 0; i < strings.length; i++) { | |||
if (strings[i].equals(prop)) { | |||
return true; | |||
} | |||
} | |||
for (String string : strings) { | |||
if (string.equals(prop)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
private String[] complement(String[] strings) { |
@@ -81,13 +81,13 @@ public class StripNonBodyHtml extends MatchingTask { | |||
log("stripping " + files.length + " files"); | |||
int stripped = 0; | |||
for (int i = 0, len = files.length; i < len; i++) { | |||
if (processFile(files[i])) { | |||
stripped++; | |||
} else { | |||
log(files[i] + " not stripped"); | |||
} | |||
} | |||
for (String file : files) { | |||
if (processFile(file)) { | |||
stripped++; | |||
} else { | |||
log(file + " not stripped"); | |||
} | |||
} | |||
log(stripped + " files successfully stripped"); | |||
} | |||
@@ -281,10 +281,10 @@ public abstract class Builder { | |||
} finally { | |||
if (0 < errors.size()) { | |||
String label = "error building " + buildSpec + ": "; | |||
for (Iterator<String> iter = errors.iterator(); iter.hasNext();) { | |||
String m = label + iter.next(); | |||
handler.error(m); | |||
} | |||
for (String error : errors) { | |||
String m = label + error; | |||
handler.error(m); | |||
} | |||
} | |||
} | |||
} | |||
@@ -294,15 +294,15 @@ public abstract class Builder { | |||
*/ | |||
public boolean cleanup() { | |||
boolean noErr = true; | |||
for (ListIterator iter = tempFiles.listIterator(); iter.hasNext();) { | |||
File file = (File) iter.next(); | |||
if (!Util.deleteContents(file) || !file.delete()) { | |||
if (noErr) { | |||
noErr = false; | |||
} | |||
handler.log("unable to clean up " + file); | |||
} | |||
} | |||
for (Object tempFile : tempFiles) { | |||
File file = (File) tempFile; | |||
if (!Util.deleteContents(file) || !file.delete()) { | |||
if (noErr) { | |||
noErr = false; | |||
} | |||
handler.log("unable to clean up " + file); | |||
} | |||
} | |||
return noErr; | |||
} | |||
@@ -345,19 +345,18 @@ public abstract class Builder { | |||
if (isLogging()) { | |||
handler.log("modules to build: " + Arrays.asList(buildList)); | |||
} | |||
for (int i = 0; i < buildList.length; i++) { | |||
Result required = buildList[i]; | |||
if (!buildingEnabled) { | |||
return false; | |||
} | |||
String requiredName = required.getName(); | |||
if (!doneList.contains(requiredName)) { | |||
doneList.add(requiredName); | |||
if (!buildOnly(required, errors)) { | |||
return false; | |||
} | |||
} | |||
} | |||
for (Result required : buildList) { | |||
if (!buildingEnabled) { | |||
return false; | |||
} | |||
String requiredName = required.getName(); | |||
if (!doneList.contains(requiredName)) { | |||
doneList.add(requiredName); | |||
if (!buildOnly(required, errors)) { | |||
return false; | |||
} | |||
} | |||
} | |||
} | |||
return true; | |||
} | |||
@@ -439,14 +438,14 @@ public abstract class Builder { | |||
handler); | |||
ProductModule[] productModules = discoverModules(buildSpec.productDir, | |||
modules); | |||
for (int i = 0; i < productModules.length; i++) { | |||
if (buildSpec.verbose) { | |||
handler.log("building product module " + productModules[i]); | |||
} | |||
if (!buildProductModule(productModules[i])) { | |||
return false; | |||
} | |||
} | |||
for (ProductModule module : productModules) { | |||
if (buildSpec.verbose) { | |||
handler.log("building product module " + module); | |||
} | |||
if (!buildProductModule(module)) { | |||
return false; | |||
} | |||
} | |||
if (buildSpec.verbose) { | |||
handler.log("assembling product module for " + buildSpec); | |||
} | |||
@@ -476,12 +475,12 @@ public abstract class Builder { | |||
String excludes = null; | |||
{ | |||
StringBuffer buf = new StringBuffer(); | |||
for (int i = 0; i < productModules.length; i++) { | |||
if (0 < buf.length()) { | |||
buf.append(","); | |||
} | |||
buf.append(productModules[i].relativePath); | |||
} | |||
for (ProductModule productModule : productModules) { | |||
if (0 < buf.length()) { | |||
buf.append(","); | |||
} | |||
buf.append(productModule.relativePath); | |||
} | |||
if (0 < buf.length()) { | |||
excludes = buf.toString(); | |||
} | |||
@@ -492,14 +491,13 @@ public abstract class Builder { | |||
} | |||
// copy binaries associated with module flag files | |||
for (int i = 0; i < productModules.length; i++) { | |||
final ProductModule product = productModules[i]; | |||
final Kind kind = Result.kind(Result.NORMAL, product.assembleAll); | |||
Result result = product.module.getResult(kind); | |||
String targPath = Util.path(targDirPath, product.relativePath); | |||
File jarFile = result.getOutputFile(); | |||
copyFile(jarFile, new File(targPath), FILTER_OFF); | |||
} | |||
for (final ProductModule product : productModules) { | |||
final Kind kind = Result.kind(Result.NORMAL, product.assembleAll); | |||
Result result = product.module.getResult(kind); | |||
String targPath = Util.path(targDirPath, product.relativePath); | |||
File jarFile = result.getOutputFile(); | |||
copyFile(jarFile, new File(targPath), FILTER_OFF); | |||
} | |||
handler.log("created product in " + targDir); | |||
// ---- create installer | |||
@@ -533,9 +531,9 @@ public abstract class Builder { | |||
Result result = module.module.getResult(productKind); | |||
return buildAll(result, errors); | |||
} finally { | |||
for (Iterator<String> iter = errors.iterator(); iter.hasNext();) { | |||
handler.error("error building " + module + ": " + iter.next()); | |||
} | |||
for (String error : errors) { | |||
handler.error("error building " + module + ": " + error); | |||
} | |||
} | |||
} | |||
@@ -595,13 +593,12 @@ public abstract class Builder { | |||
File library = liter.next(); | |||
final String fname = library.getName(); | |||
if (null != fname) { | |||
for (Iterator<String> iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) { | |||
String name = iter.next(); | |||
if (fname.equals(name)) { | |||
liter.remove(); | |||
break; | |||
} | |||
} | |||
for (String name : SKIP_LIBRARIES) { | |||
if (fname.equals(name)) { | |||
liter.remove(); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -79,13 +79,13 @@ public class Module { | |||
return; | |||
} | |||
File[] files = srcDir.listFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
if (files[i].isDirectory()) { | |||
sourceFiles(files[i], result); | |||
} else if (isSourceFile(files[i])) { | |||
result.add(files[i]); | |||
} | |||
} | |||
for (File file : files) { | |||
if (file.isDirectory()) { | |||
sourceFiles(file, result); | |||
} else if (isSourceFile(file)) { | |||
result.add(file); | |||
} | |||
} | |||
} | |||
private static void addIfNew(List<File> source, List<File> sink) { | |||
@@ -107,14 +107,13 @@ public class Module { | |||
addIfNew(result.getLibJars(), known); | |||
addIfNew(result.getExportedLibJars(), known); | |||
Result[] reqs = result.getRequired(); | |||
for (int i = 0; i < reqs.length; i++) { | |||
Result requiredResult = reqs[i]; | |||
File requiredJar = requiredResult.getOutputFile(); | |||
if (!known.contains(requiredJar)) { | |||
known.add(requiredJar); | |||
doFindJarRequirements(requiredResult, known); | |||
} | |||
} | |||
for (Result requiredResult : reqs) { | |||
File requiredJar = requiredResult.getOutputFile(); | |||
if (!known.contains(requiredJar)) { | |||
known.add(requiredJar); | |||
doFindJarRequirements(requiredResult, known); | |||
} | |||
} | |||
} | |||
/** @return true if this is a source file */ | |||
@@ -238,31 +237,29 @@ public class Module { | |||
} | |||
final long time = outputFile.lastModified(); | |||
File file; | |||
for (Iterator<File> iter = result.getSrcDirs().iterator(); iter.hasNext();) { | |||
File srcDir = iter.next(); | |||
for (Iterator<File> srcFiles = sourceFiles(srcDir); srcFiles.hasNext();) { | |||
file = srcFiles.next(); | |||
if (outOfDate(time, file)) { | |||
return true; | |||
} | |||
} | |||
} | |||
for (File srcDir : result.getSrcDirs()) { | |||
for (Iterator<File> srcFiles = sourceFiles(srcDir); srcFiles.hasNext(); ) { | |||
file = srcFiles.next(); | |||
if (outOfDate(time, file)) { | |||
return true; | |||
} | |||
} | |||
} | |||
// required modules | |||
Result[] reqs = result.getRequired(); | |||
for (int i = 0; i < reqs.length; i++) { | |||
Result requiredResult = reqs[i]; | |||
file = requiredResult.getOutputFile(); | |||
if (outOfDate(time, file)) { | |||
return true; | |||
} | |||
} | |||
for (Result requiredResult : reqs) { | |||
file = requiredResult.getOutputFile(); | |||
if (outOfDate(time, file)) { | |||
return true; | |||
} | |||
} | |||
// libraries | |||
for (Iterator<File> iter = result.getLibJars().iterator(); iter.hasNext();) { | |||
file = iter.next(); | |||
if (outOfDate(time, file)) { | |||
return true; | |||
} | |||
} | |||
for (File value : result.getLibJars()) { | |||
file = value; | |||
if (outOfDate(time, file)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
@@ -345,14 +342,13 @@ public class Module { | |||
Util.closeSilently(fin); | |||
} | |||
RequiredBundle[] bundles = bundle.getRequiredBundles(); | |||
for (int i = 0; i < bundles.length; i++) { | |||
RequiredBundle required = bundles[i]; | |||
update("src", "/" + required.name, required.text, false); | |||
} | |||
for (RequiredBundle required : bundles) { | |||
update("src", "/" + required.name, required.text, false); | |||
} | |||
String[] libs = bundle.getClasspath(); | |||
for (int i = 0; i < libs.length; i++) { | |||
update("lib", libs[i], libs[i], false); | |||
} | |||
for (String lib : libs) { | |||
update("lib", lib, lib, false); | |||
} | |||
return true; | |||
} | |||
@@ -478,11 +474,11 @@ public class Module { | |||
private void warnVariable(String path, String toString) { | |||
String[] known = { "JRE_LIB", "ASPECTJRT_LIB", "JRE15_LIB" }; | |||
for (int i = 0; i < known.length; i++) { | |||
if (known[i].equals(path)) { | |||
return; | |||
} | |||
} | |||
for (String s : known) { | |||
if (s.equals(path)) { | |||
return; | |||
} | |||
} | |||
messager.log("Module cannot handle var yet: " + toString); | |||
} | |||
@@ -645,9 +641,9 @@ public class Module { | |||
public void acceptLine(String line) { | |||
String[] tokens = tokenize(line); | |||
for (int i = 0; i < tokens.length; i++) { | |||
next(tokens[i]); | |||
} | |||
for (String token : tokens) { | |||
next(token); | |||
} | |||
} | |||
private Properties attributesToProperties() { |
@@ -89,9 +89,9 @@ public class SampleGatherer { | |||
return; | |||
} | |||
Samples result = new Samples(); | |||
for (int i = 0; i < args.length; i++) { | |||
result = gather(new File(args[i]), result); | |||
} | |||
for (String arg : args) { | |||
result = gather(new File(arg), result); | |||
} | |||
StringBuffer sb = HTMLSamplesRenderer.ME.render(result, null); | |||
@@ -144,9 +144,9 @@ public class SampleGatherer { | |||
} | |||
} else if (source.isDirectory() && source.canRead()) { | |||
File[] files = source.listFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
doGather(files[i], sink); | |||
} | |||
for (File file : files) { | |||
doGather(file, sink); | |||
} | |||
} | |||
} | |||
@@ -156,11 +156,11 @@ public class SampleGatherer { | |||
} | |||
String path = file.getName().toLowerCase(); | |||
String[] suffixes = Sample.Kind.SOURCE_SUFFIXES; | |||
for (int i = 0; i < suffixes.length; i++) { | |||
if (path.endsWith(suffixes[i])) { | |||
return true; | |||
} | |||
} | |||
for (String suffix : suffixes) { | |||
if (path.endsWith(suffix)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
@@ -451,7 +451,8 @@ class SamplesRenderer { | |||
public static final String COPYRIGHT = | |||
"<p><small>Copyright 2003 Contributors. All Rights Reserved. " | |||
+ "This sample code is made available under the Common Public " + "License version 1.0 available at " | |||
+ "This sample code is made available under the Common Public " | |||
+ "License version 1.0 available at " | |||
+ "<a href=\"http://www.eclipse.org/legal/epl-v10.html\">" | |||
+ "http://www.eclipse.org/legal/epl-v10.html</a>." | |||
+ "Contributors are listed in this document as authors. " | |||
@@ -473,18 +474,16 @@ class SamplesRenderer { | |||
startList(samples, sink); | |||
List<Sample> list = samples.getSortedSamples(); | |||
String anchorName = null; | |||
for (ListIterator<Sample> iter = list.listIterator(); | |||
iter.hasNext();) { | |||
Sample sample = iter.next(); | |||
String newAnchorName = sample.anchorName; | |||
if ((null == anchorName) | |||
|| (!anchorName.equals(newAnchorName))) { | |||
endAnchorName(anchorName, sink); | |||
startAnchorName(newAnchorName, sample.anchorTitle, sink); | |||
anchorName = newAnchorName; | |||
} | |||
render(sample, sink); | |||
} | |||
for (Sample sample : list) { | |||
String newAnchorName = sample.anchorName; | |||
if ((null == anchorName) | |||
|| (!anchorName.equals(newAnchorName))) { | |||
endAnchorName(anchorName, sink); | |||
startAnchorName(newAnchorName, sample.anchorTitle, sink); | |||
anchorName = newAnchorName; | |||
} | |||
render(sample, sink); | |||
} | |||
endAnchorName(anchorName, sink); | |||
endList(samples, sink); | |||
return sink; | |||
@@ -605,17 +604,16 @@ class HTMLSamplesRenderer extends SamplesRenderer { | |||
sampleSection.append(EOL); | |||
if (doFlags) { | |||
boolean flagHeaderDone = false; | |||
for (Iterator iter = sample.flags.iterator(); iter.hasNext();) { | |||
String flag = (String) iter.next(); | |||
if (!flagHeaderDone) { | |||
sampleSection.append("<p>Comments flagged:<ul>"); | |||
sampleSection.append(EOL); | |||
flagHeaderDone = true; | |||
} | |||
sampleSection.append("<li>"); | |||
sampleSection.append(flag); | |||
sampleSection.append("</li>"); | |||
} | |||
for (String flag : sample.flags) { | |||
if (!flagHeaderDone) { | |||
sampleSection.append("<p>Comments flagged:<ul>"); | |||
sampleSection.append(EOL); | |||
flagHeaderDone = true; | |||
} | |||
sampleSection.append("<li>"); | |||
sampleSection.append(flag); | |||
sampleSection.append("</li>"); | |||
} | |||
if (flagHeaderDone) { | |||
sampleSection.append("</ul>"); | |||
sampleSection.append(EOL); | |||
@@ -779,30 +777,29 @@ class HTMLSamplesRenderer extends SamplesRenderer { | |||
sink.append("<h2><a name=\"authorIndex\"></a>Author Index</h2>"); | |||
List<Sample> list = samples.getSortedSamples(Sample.AUTHOR_NAME_SOURCE_COMPARER); | |||
String lastAuthor = null; | |||
for (ListIterator<Sample> iter = list.listIterator(); iter.hasNext();) { | |||
Sample sample = iter.next(); | |||
String author = sample.author; | |||
if (!author.equals(lastAuthor)) { | |||
if (null != lastAuthor) { | |||
sink.append("</li></ul>"); | |||
} | |||
sink.append("<li>"); | |||
sink.append(author); | |||
sink.append(EOL); | |||
sink.append("<ul>"); | |||
sink.append(EOL); | |||
lastAuthor = author; | |||
} | |||
sink.append(" <li><a href=\"#"); | |||
sink.append(sample.anchorName); | |||
sink.append("\">"); | |||
if (null == sample.anchorTitle) { | |||
sink.append(sample.anchorName); | |||
} else { | |||
sink.append(sample.anchorTitle); | |||
} | |||
sink.append("</a></li>"); | |||
} | |||
for (Sample sample : list) { | |||
String author = sample.author; | |||
if (!author.equals(lastAuthor)) { | |||
if (null != lastAuthor) { | |||
sink.append("</li></ul>"); | |||
} | |||
sink.append("<li>"); | |||
sink.append(author); | |||
sink.append(EOL); | |||
sink.append("<ul>"); | |||
sink.append(EOL); | |||
lastAuthor = author; | |||
} | |||
sink.append(" <li><a href=\"#"); | |||
sink.append(sample.anchorName); | |||
sink.append("\">"); | |||
if (null == sample.anchorTitle) { | |||
sink.append(sample.anchorName); | |||
} else { | |||
sink.append(sample.anchorTitle); | |||
} | |||
sink.append("</a></li>"); | |||
} | |||
} | |||
} | |||
@@ -812,11 +809,10 @@ class SampleUtil { | |||
public static void simpleRender(Samples result, StringBuffer sink) { | |||
List sortedSamples = result.getSortedSamples(); | |||
int i = 0; | |||
for (ListIterator iter = sortedSamples.listIterator(); | |||
iter.hasNext();) { | |||
Sample sample = (Sample) iter.next(); | |||
sink.append(i++ + ": " + sample); | |||
} | |||
for (Object sortedSample : sortedSamples) { | |||
Sample sample = (Sample) sortedSample; | |||
sink.append(i++ + ": " + sample); | |||
} | |||
} | |||
/** result struct for getPackagePath */ |
@@ -193,10 +193,10 @@ public class Util { | |||
return false; | |||
} else if (dir.isDirectory()) { | |||
File[] files = dir.listFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
if (!deleteContents(files[i]) || !files[i].delete()) { | |||
return false; | |||
} | |||
for (File file : files) { | |||
if (!deleteContents(file) || !file.delete()) { | |||
return false; | |||
} | |||
} | |||
} | |||
return true; | |||
@@ -293,26 +293,26 @@ public class Util { | |||
if ((hits != expected.length) || (hits != actual.length)) { | |||
sb.append("unexpected ["); | |||
String prefix = ""; | |||
for (int i = 0; i < actual.length; i++) { | |||
if (null != actual[i]) { | |||
sb.append(prefix); | |||
prefix = ", "; | |||
sb.append("\""); | |||
sb.append(actual[i]); | |||
sb.append("\""); | |||
} | |||
} | |||
for (String value : actual) { | |||
if (null != value) { | |||
sb.append(prefix); | |||
prefix = ", "; | |||
sb.append("\""); | |||
sb.append(value); | |||
sb.append("\""); | |||
} | |||
} | |||
sb.append("] missing ["); | |||
prefix = ""; | |||
for (int i = 0; i < expected.length; i++) { | |||
if (null != expected[i]) { | |||
sb.append(prefix); | |||
prefix = ", "; | |||
sb.append("\""); | |||
sb.append(expected[i]); | |||
sb.append("\""); | |||
} | |||
} | |||
for (String s : expected) { | |||
if (null != s) { | |||
sb.append(prefix); | |||
prefix = ", "; | |||
sb.append("\""); | |||
sb.append(s); | |||
sb.append("\""); | |||
} | |||
} | |||
sb.append("]"); | |||
return true; | |||
} |
@@ -114,8 +114,8 @@ public class BuildModuleTests extends TestCase { | |||
public void testLicense_org_eclipse_jdt_core() { | |||
final String mod = "org.eclipse.jdt.core"; | |||
final String pre = BASE_DIR + mod + File.separator; | |||
for (int i = 0; i < JDT_SOURCE_DIRS.length; i++) { | |||
checkSourceDirectory(new File(pre + JDT_SOURCE_DIRS[i]), mod); | |||
for (String jdtSourceDir : JDT_SOURCE_DIRS) { | |||
checkSourceDirectory(new File(pre + jdtSourceDir), mod); | |||
} | |||
} | |||
@@ -167,10 +167,10 @@ public class BuildModuleTests extends TestCase { | |||
void checkLicense(String module) { | |||
File moduleDir = new File(Util.path("..", module)); | |||
File[] srcDirs = findSourceRoots(moduleDir); | |||
for (int i = 0; i < srcDirs.length; i++) { | |||
System.out.println(srcDirs[i]); | |||
checkSourceDirectory(srcDirs[i], module); | |||
} | |||
for (File srcDir : srcDirs) { | |||
System.out.println(srcDir); | |||
checkSourceDirectory(srcDir, module); | |||
} | |||
} | |||
void checkSourceDirectory(File srcDir, String module) { | |||
@@ -294,17 +294,16 @@ public class BuildModuleTests extends TestCase { | |||
} | |||
void unknownFiles(File dir, ArrayList<File> results) { | |||
File[] files = dir.listFiles(this); | |||
for (int j = 0; j < files.length; j++) { | |||
File file = files[j]; | |||
if (file.isDirectory()) { | |||
String name = file.getName(); | |||
if (!("CVS".equals(name))) { | |||
unknownFiles(file, results); | |||
} | |||
} else { | |||
results.add(file); | |||
} | |||
} | |||
for (File file : files) { | |||
if (file.isDirectory()) { | |||
String name = file.getName(); | |||
if (!("CVS".equals(name))) { | |||
unknownFiles(file, results); | |||
} | |||
} else { | |||
results.add(file); | |||
} | |||
} | |||
} | |||
} |
@@ -106,24 +106,23 @@ public class BuildModuleTest extends TestCase { | |||
} | |||
protected void deleteTempFiles() { | |||
for (Iterator iter = tempFiles.iterator(); iter.hasNext();) { | |||
File file = (File) iter.next(); | |||
if (!Util.delete(file)) { | |||
File[] list = file.listFiles(); | |||
if (!Util.isEmpty(list)) { | |||
StringBuffer sb = new StringBuffer(); | |||
sb.append("warning: BuildModuleTest unable to delete "); | |||
sb.append(file.toString()); | |||
sb.append("\n"); // XXX platform | |||
for (int i = 0; i < list.length; i++) { | |||
sb.append(" "); | |||
sb.append(list[i].toString()); | |||
sb.append("\n"); // XXX platform | |||
} | |||
System.err.println(sb.toString()); | |||
} | |||
} | |||
} | |||
for (File file : tempFiles) { | |||
if (!Util.delete(file)) { | |||
File[] list = file.listFiles(); | |||
if (!Util.isEmpty(list)) { | |||
StringBuffer sb = new StringBuffer(); | |||
sb.append("warning: BuildModuleTest unable to delete "); | |||
sb.append(file.toString()); | |||
sb.append("\n"); // XXX platform | |||
for (File value : list) { | |||
sb.append(" "); | |||
sb.append(value.toString()); | |||
sb.append("\n"); // XXX platform | |||
} | |||
System.err.println(sb.toString()); | |||
} | |||
} | |||
} | |||
} | |||
public void testAllJunitTests() { | |||
@@ -318,21 +317,21 @@ public class BuildModuleTest extends TestCase { | |||
printedMessage = true; | |||
} | |||
if (debugging()) { | |||
for (int i = 0; i < DEBUGS.length; i++) { | |||
if (target.equals(DEBUGS[i])) { | |||
return true; | |||
} | |||
} | |||
for (String debug : DEBUGS) { | |||
if (target.equals(debug)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} else { | |||
for (int i = 0; i < SKIPS.length; i++) { | |||
if (SKIPS[i].equals(target)) { | |||
if (printInfoMessages) { | |||
System.err.println(target + " skipped build test [" + getClass().getName() + ".shouldBuild(..)]"); | |||
} | |||
return false; | |||
} | |||
} | |||
for (String skip : SKIPS) { | |||
if (skip.equals(target)) { | |||
if (printInfoMessages) { | |||
System.err.println(target + " skipped build test [" + getClass().getName() + ".shouldBuild(..)]"); | |||
} | |||
return false; | |||
} | |||
} | |||
} | |||
return building; | |||
} | |||
@@ -419,10 +418,10 @@ public class BuildModuleTest extends TestCase { | |||
java.setClasspath(cp); | |||
java.setClassname(classname); | |||
if (null != args) { | |||
for (int i = 0; i < args.length; i++) { | |||
Argument arg = java.createArg(); | |||
arg.setValue(args[i]); | |||
} | |||
for (String s : args) { | |||
Argument arg = java.createArg(); | |||
arg.setValue(s); | |||
} | |||
} | |||
try { | |||
java.execute(); |
@@ -62,12 +62,12 @@ public class ModulesTest extends TestCase { | |||
} else { | |||
File[] files = file.listFiles(); | |||
boolean result = true; | |||
for (int i = 0; i < files.length; i++) { | |||
if (!ModulesTest.delete(files[i]) | |||
&& result) { | |||
result = false; | |||
} | |||
} | |||
for (File value : files) { | |||
if (!ModulesTest.delete(value) | |||
&& result) { | |||
result = false; | |||
} | |||
} | |||
return (file.delete() && result); | |||
} | |||
} | |||
@@ -80,11 +80,10 @@ public class ModulesTest extends TestCase { | |||
protected void tearDown() throws Exception { | |||
super.tearDown(); | |||
for (Iterator<File> iter = tempFiles.iterator(); iter.hasNext();) { | |||
File file = (File) iter.next(); | |||
if (!ModulesTest.delete(file)) { | |||
System.err.println("warning: ModulesTest unable to delete " + file); | |||
} | |||
for (File file : tempFiles) { | |||
if (!ModulesTest.delete(file)) { | |||
System.err.println("warning: ModulesTest unable to delete " + file); | |||
} | |||
} | |||
} | |||
@@ -270,13 +269,13 @@ public class ModulesTest extends TestCase { | |||
File libDir = new File(distDir, "tools/lib"); | |||
String[] jars = { "tools", "rt", "weaver", "lib"}; | |||
for (int i = 0; i < jars.length; i++) { | |||
File jar = new File(libDir, "aspectj" + jars[i] + ".jar"); | |||
assertTrue(jar.getPath(), jar.canRead()); | |||
if (10 > jar.length()) { | |||
assertTrue(jar + " too small", false); | |||
} | |||
} | |||
for (String s : jars) { | |||
File jar = new File(libDir, "aspectj" + s + ".jar"); | |||
assertTrue(jar.getPath(), jar.canRead()); | |||
if (10 > jar.length()) { | |||
assertTrue(jar + " too small", false); | |||
} | |||
} | |||
} | |||
/** | |||
* Show messages from the task. |
@@ -49,21 +49,20 @@ public class UtilsTest extends TestCase { | |||
"aspectjrt" }) { | |||
void checkOthers(OSGIBundle osgiBundle, StringBuffer sb) { | |||
RequiredBundle[] bundles = osgiBundle.getRequiredBundles(); | |||
for (int i = 0; i < bundles.length; i++) { | |||
RequiredBundle bundle = bundles[i]; | |||
if ("aspectjrt".equals(bundle.name)) { | |||
if (!bundle.optional) { | |||
sb | |||
.append("expected required bundle aspectjrt to be optional"); | |||
} | |||
String version = "[1.5.0,1.5.5]"; | |||
if (!(version.equals(bundle.versions))) { | |||
sb.append("expected version " + version | |||
+ " got " + bundle.versions | |||
+ " for required bundle aspectjrt"); | |||
} | |||
} | |||
} | |||
for (RequiredBundle bundle : bundles) { | |||
if ("aspectjrt".equals(bundle.name)) { | |||
if (!bundle.optional) { | |||
sb | |||
.append("expected required bundle aspectjrt to be optional"); | |||
} | |||
String version = "[1.5.0,1.5.5]"; | |||
if (!(version.equals(bundle.versions))) { | |||
sb.append("expected version " + version | |||
+ " got " + bundle.versions | |||
+ " for required bundle aspectjrt"); | |||
} | |||
} | |||
} | |||
} | |||
} }; | |||
@@ -140,9 +139,9 @@ public class UtilsTest extends TestCase { | |||
/** disabled pending research */ | |||
public void skip_testOSGIManifests() throws Exception { | |||
StringBuffer sb = new StringBuffer(); | |||
for (int i = 0; i < TESTS.length; i++) { | |||
TESTS[i].run(sb); | |||
} | |||
for (ManifestTest test : TESTS) { | |||
test.run(sb); | |||
} | |||
if (0 < sb.length()) { | |||
fail(sb.toString()); | |||
} |
@@ -199,8 +199,7 @@ public class Aj implements ClassPreProcessor { | |||
System.err.println("Weaver adaptors before queue processing:"); | |||
Map<AdaptorKey,ExplicitlyInitializedClassLoaderWeavingAdaptor> m = WeaverContainer.weavingAdaptors; | |||
Set<AdaptorKey> keys = m.keySet(); | |||
for (Iterator<AdaptorKey> iterator = keys.iterator(); iterator.hasNext();) { | |||
Object object = iterator.next(); | |||
for (Object object : keys) { | |||
System.err.println(object + " = " + WeaverContainer.weavingAdaptors.get(object)); | |||
} | |||
} | |||
@@ -223,8 +222,7 @@ public class Aj implements ClassPreProcessor { | |||
System.err.println("Weaver adaptors after queue processing:"); | |||
Map<AdaptorKey,ExplicitlyInitializedClassLoaderWeavingAdaptor> m = WeaverContainer.weavingAdaptors; | |||
Set<AdaptorKey> keys = m.keySet(); | |||
for (Iterator<AdaptorKey> iterator = keys.iterator(); iterator.hasNext();) { | |||
Object object = iterator.next(); | |||
for (Object object : keys) { | |||
System.err.println(object + " = " + WeaverContainer.weavingAdaptors.get(object)); | |||
} | |||
} |