diff options
249 files changed, 759 insertions, 985 deletions
diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..e1a90164c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +[*.yml] +indent_style = space +indent_size = 2 + +[*.xml] +trim_trailing_whitespace = true + +[*.{java,aj}] +charset = utf-8 +trim_trailing_whitespace = true diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index bd6b8d225..4657a3dec 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,6 +24,6 @@ jobs: with: java-version: ${{ matrix.java }} - run: java -version - - run: mvn --version + - run: ./mvnw --version - name: Build with Maven - run: mvn -Daspectj.tests.verbose=false -B package --file pom.xml + run: ./mvnw -Daspectj.tests.verbose=false -B package --file pom.xml diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index fa4f7b499..b901097f2 100755..100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -1,22 +1,18 @@ /* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ - + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import java.net.*; import java.io.*; import java.nio.channels.*; @@ -24,11 +20,12 @@ import java.util.Properties; public class MavenWrapperDownloader { + private static final String WRAPPER_VERSION = "0.5.6"; /** * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */ - private static final String DEFAULT_DOWNLOAD_URL = - "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; /** * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to @@ -76,13 +73,13 @@ public class MavenWrapperDownloader { } } } - System.out.println("- Downloading from: : " + url); + System.out.println("- Downloading from: " + url); File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); if(!outputFile.getParentFile().exists()) { if(!outputFile.getParentFile().mkdirs()) { System.out.println( - "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); } } System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); @@ -98,6 +95,16 @@ public class MavenWrapperDownloader { } private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } URL website = new URL(urlString); ReadableByteChannel rbc; rbc = Channels.newChannel(website.openStream()); diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar Binary files differindex 01e679973..2cc7d4a55 100755..100644 --- a/.mvn/wrapper/maven-wrapper.jar +++ b/.mvn/wrapper/maven-wrapper.jar diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 00d32aab1..642d572ce 100755..100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,2 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
\ No newline at end of file +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java index 0295a9a24..254696531 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java @@ -12,7 +12,6 @@ package org.aspectj.tools.ajbrowser.core; import java.io.File; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/EditorManager.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/EditorManager.java index b737cf07e..249992dd7 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/EditorManager.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/EditorManager.java @@ -17,6 +17,7 @@ import java.awt.BorderLayout; import java.awt.event.KeyEvent; import java.io.IOException; import java.util.ArrayList; +import java.util.List; import java.util.Vector; import javax.swing.Box; @@ -43,7 +44,7 @@ public class EditorManager { private EditorAdapter editor = null; private BasicEditor basicEditor = null; - private ArrayList<EditorListener> editorListeners = new ArrayList<>(); + private List<EditorListener> editorListeners = new ArrayList<>(); private Vector<EditorAdapter> editors = new Vector<>(); private JPanel editor_panel = null; private Box editors_box = Box.createVerticalBox(); diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java index d3abd95eb..26ec8f00c 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java @@ -14,7 +14,6 @@ import java.awt.BorderLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.util.Iterator; import java.util.List; import javax.swing.DefaultListModel; diff --git a/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java b/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java index 49948db46..e9f3a1b86 100644 --- a/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java +++ b/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java @@ -225,8 +225,7 @@ public class AjdeCoreBuildManager { if (projectSourceFiles == null) { return null; } - List<String> l = new ArrayList<>(); - l.addAll(projectSourceFiles); + List<String> l = new ArrayList<>(projectSourceFiles); // If the processor options are specified build the command line options for the JDT compiler to see String processor = compilerConfig.getProcessor(); if (processor != null && processor.length() != 0) { @@ -256,7 +255,7 @@ public class AjdeCoreBuildManager { } args[p++] = "-xmlConfigured"; } else { - args = l.toArray(new String[l.size()]); + args = l.toArray(new String[0]); } } @@ -279,7 +278,7 @@ public class AjdeCoreBuildManager { } } if (0 < toAdd.size()) { - ArrayList<String> both = new ArrayList<>(configClasspath.size() + toAdd.size()); + List<String> both = new ArrayList<>(configClasspath.size() + toAdd.size()); both.addAll(configClasspath); both.addAll(toAdd); config.setClasspath(both); diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java index c5fa43e16..1c8aa7108 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java @@ -28,7 +28,6 @@ import org.aspectj.ajde.core.JavaOptions; import org.aspectj.ajde.core.TestCompilerConfiguration; import org.aspectj.ajde.core.TestMessageHandler; import org.aspectj.bridge.IMessage; -import org.aspectj.util.LangUtil; /** * Weaving messages are complicated things. There are multiple places where weaving takes place and the places vary depending on @@ -367,8 +366,7 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { String line = null; while ((line = fr.readLine()) != null) fileContents.add(line); - List<String> originalFileContents = new ArrayList<>(); - originalFileContents.addAll(fileContents); + List<String> originalFileContents = new ArrayList<>(fileContents); // See if the messages match int msgCount = 0; diff --git a/ajde/src/main/java/org/aspectj/ajde/Ajde.java b/ajde/src/main/java/org/aspectj/ajde/Ajde.java index b458eb9da..14995d75d 100644 --- a/ajde/src/main/java/org/aspectj/ajde/Ajde.java +++ b/ajde/src/main/java/org/aspectj/ajde/Ajde.java @@ -18,7 +18,6 @@ import java.awt.Frame; import java.io.File; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import javax.swing.JOptionPane; diff --git a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java index 4ca7316f4..ece904adf 100644 --- a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java +++ b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java @@ -21,7 +21,6 @@ import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeSet; diff --git a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java index cde164cc1..2837de76b 100644 --- a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java @@ -20,7 +20,6 @@ import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import org.aspectj.ajde.Ajde; @@ -291,7 +290,7 @@ public class LstBuildConfigManager implements BuildConfigManager { private void sortModel(BuildConfigNode node, Comparator<BuildConfigNode> comparator) { if (node == null || node.getChildren() == null) return; - Collections.sort(node.getChildren(), comparator); + node.getChildren().sort(comparator); for (BuildConfigNode nextNode : node.getChildren()) { if (nextNode != null) sortModel(nextNode, comparator); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java index 8839b00da..ce0560287 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java @@ -15,7 +15,6 @@ package org.aspectj.ajde.ui; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java index 7d6e4838b..4a10462a2 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java @@ -14,8 +14,6 @@ package org.aspectj.ajde.ui; -import java.util.Iterator; - import org.aspectj.asm.IProgramElement; /** diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java index 9b23439e4..8fa1c7539 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java @@ -15,7 +15,6 @@ package org.aspectj.ajde.ui; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.ajde.Ajde; @@ -36,7 +35,7 @@ public class StructureViewManager { // private String buildConfigFilePath = null; private final NavigationHistoryModel historyModel = new NavigationHistoryModel(); - private final ArrayList structureViews = new ArrayList(); + private final List structureViews = new ArrayList(); private FileStructureView defaultFileView = null; private static final StructureViewProperties DEFAULT_VIEW_PROPERTIES; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java index 43513c14b..afefbbe18 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java @@ -13,7 +13,6 @@ package org.aspectj.ajde.ui; -import java.util.Iterator; import java.util.List; import org.aspectj.ajde.Ajde; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 23f999ac8..a8a07ee34 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -196,7 +196,7 @@ public class TreeStructureViewBuilder { private void sortView(IStructureViewNode node, Comparator<IStructureViewNode> comparator) { if (node == null || node.getChildren() == null) return; - Collections.sort(node.getChildren(), comparator); + node.getChildren().sort(comparator); for (Object o : node.getChildren()) { IStructureViewNode nextNode = (IStructureViewNode) o; if (nextNode != null) sortView(nextNode, comparator); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java b/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java index 611af0b4e..b827e9231 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java @@ -21,7 +21,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.StringTokenizer; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java index 51248d6c4..d00146ff9 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java @@ -14,7 +14,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.io.IOException; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java index 6431eb851..10601a27b 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java @@ -19,7 +19,6 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Iterator; import javax.swing.ButtonGroup; import javax.swing.Icon; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java index e9c1196e2..de7a16d54 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java @@ -23,7 +23,6 @@ import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; import java.io.File; -import java.util.Iterator; import javax.swing.BorderFactory; import javax.swing.JButton; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java index a32c53c52..5459e916f 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java @@ -18,7 +18,6 @@ package org.aspectj.ajde.ui.swing; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; -import java.util.Iterator; import javax.swing.JComboBox; import javax.swing.JPanel; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java index 0a59ab71a..f1aca6bcd 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java @@ -17,7 +17,6 @@ package org.aspectj.ajde.ui.swing; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Iterator; import java.util.List; import javax.swing.AbstractAction; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/PointcutWizard.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/PointcutWizard.java index fb461d132..f80ff76e6 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/PointcutWizard.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/PointcutWizard.java @@ -17,6 +17,7 @@ package org.aspectj.ajde.ui.swing; import java.awt.BorderLayout; //import java.awt.event.ActionEvent; import java.util.ArrayList; +import java.util.List; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -55,7 +56,7 @@ class PointcutWizard extends JFrame { public PointcutWizard(java.util.List signatures) { // this.signatures = signatures; - ArrayList views = new ArrayList(); + List views = new ArrayList(); views.add(StructureViewProperties.Hierarchy.INHERITANCE); // typeTreeView = new BrowserViewPanel(AjdeUIManager.getDefault().getIconRegistry(), views, StructureViewProperties.Hierarchy.INHERITANCE); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java index add41298c..c3e87bcf8 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java @@ -17,7 +17,6 @@ package org.aspectj.ajde.ui.swing; import java.awt.BorderLayout; import java.awt.Color; -import java.util.Iterator; import javax.swing.BorderFactory; import javax.swing.JPanel; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java index ef756f6e4..987c2d130 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java @@ -15,7 +15,6 @@ package org.aspectj.ajde.ui.swing; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.swing.tree.DefaultMutableTreeNode; diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java index 02f9aaf8f..9e8b21fb5 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java @@ -26,7 +26,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import javax.swing.BoxLayout; import javax.swing.Icon; diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java index ce0269930..384d417f7 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java @@ -11,7 +11,6 @@ package org.aspectj.ajde; import java.io.File; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java index fe642ff95..74a8cc1eb 100644 --- a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -28,10 +28,6 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { private BuildConfigManager buildConfigManager = new LstBuildConfigManager(); - public static void main(String[] args) { - junit.swingui.TestRunner.run(LstBuildConfigManagerTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(LstBuildConfigManagerTest.class); diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java index 1dc3d9928..ecbfed0d7 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java @@ -26,10 +26,6 @@ import junit.framework.TestSuite; * @author Mik Kersten */ public class StructureSearchManagerTest extends AjdeTestCase { - - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureSearchManagerTest.class); - } public static TestSuite suite() { TestSuite result = new TestSuite(); diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java index eca56feec..5948d2c5a 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java @@ -14,7 +14,6 @@ package org.aspectj.ajde.ui; import java.io.File; -import java.util.Iterator; import org.aspectj.ajde.Ajde; import org.aspectj.ajde.AjdeTestCase; @@ -38,10 +37,6 @@ public class StructureViewManagerTest extends AjdeTestCase { private File testFile; private StructureViewProperties properties; - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureViewManagerTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(StructureViewManagerTest.class); diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java index 41d13e37e..42d029e06 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -897,7 +897,7 @@ class HtmlDecorator { }; file.walk(walker); - return (IProgramElement[]) nodes.toArray(new IProgramElement[nodes.size()]); + return (IProgramElement[]) nodes.toArray(new IProgramElement[0]); } /** diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java index adf22bf12..e1bbd9ad4 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/JavadocRunner.java @@ -28,7 +28,7 @@ import javax.tools.ToolProvider; */ class JavadocRunner { - public static void callJavadocViaToolProvider(Vector<String> options, List<String> files) { + public static void callJavadocViaToolProvider(Iterable<String> options, List<String> files) { DocumentationTool doctool = ToolProvider.getSystemDocumentationTool(); StandardJavaFileManager fm = doctool.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> jfos = fm.getJavaFileObjects(files.toArray(new String[0])); diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java index 26857b41c..e65c8901f 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/Main.java @@ -22,14 +22,7 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.FilenameFilter; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; +import java.util.*; import org.aspectj.asm.AsmManager; import org.aspectj.bridge.IMessage; @@ -164,7 +157,7 @@ public class Main implements Config { * package-summary properly. */ private static void packageHTML(AsmManager model, File[] inputFiles) throws IOException { - ArrayList<String> dirList = new ArrayList<>(); + List<String> dirList = new ArrayList<>(); for (File inputFile : inputFiles) { String packageName = StructureUtil.getPackageDeclarationFromFile(model, inputFile); // Only copy the package.html file once. @@ -262,9 +255,7 @@ public class Main implements Config { javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k); } options = new Vector<>(); - for (String a: javadocargs) { - options.add(a); - } + Collections.addAll(options, javadocargs); } else { javadocargs = new String[options.size() + signatureFiles.length]; for (int k = 0; k < options.size(); k++) { diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StructureUtil.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StructureUtil.java index d4cdb9cd5..4db92d66a 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StructureUtil.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StructureUtil.java @@ -13,7 +13,6 @@ package org.aspectj.tools.ajdoc; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java index 4b9301ce8..64d7aebf2 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java @@ -20,8 +20,8 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; +import java.util.Map; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IProgramElement; @@ -32,7 +32,7 @@ import org.aspectj.util.FileUtil; */ class StubFileGenerator { - static Hashtable declIDTable = null; + static Map declIDTable = null; static void doFiles(AsmManager model, Hashtable table, File[] inputFiles, File[] signatureFiles) throws DocException { declIDTable = table; diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java index 6dfd5633f..acfb5eda4 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java @@ -12,7 +12,6 @@ package org.aspectj.tools.ajdoc; import java.io.File; import java.io.IOException; -import java.util.Iterator; import java.util.List; import org.aspectj.testing.util.TestUtil; @@ -178,9 +177,7 @@ public abstract class AjdocTestCase extends TestCase { args[3] = AjdocTests.ASPECTJRT_PATH.getPath(); args[4] = "-d"; args[5] = getAbsolutePathOutdir(); - for (int i = 0; i < ajOptions.length; i++) { - args[6 + i] = ajOptions[i]; - } + System.arraycopy(ajOptions, 0, args, 6, ajOptions.length); for (int i = 0; i < inputFiles.length; i++) { args[6 + i + ajOptions.length] = inputFiles[i].getAbsolutePath(); } @@ -252,9 +249,7 @@ public abstract class AjdocTestCase extends TestCase { args[4] = getAbsolutePathOutdir(); args[5] = "-sourcepath"; args[6] = getAbsoluteProjectDir(); - for (int i = 0; i < directoryNames.length; i++) { - args[7 + i] = directoryNames[i]; - } + System.arraycopy(directoryNames, 0, args, 7, directoryNames.length); org.aspectj.tools.ajdoc.Main.main(args); } @@ -272,9 +267,7 @@ public abstract class AjdocTestCase extends TestCase { args[3] = getAbsolutePathOutdir(); args[4] = "-sourcepath"; args[5] = getAbsoluteProjectDir(); - for (int i = 0; i < directoryNames.length; i++) { - args[6 + i] = directoryNames[i]; - } + System.arraycopy(directoryNames, 0, args, 6, directoryNames.length); org.aspectj.tools.ajdoc.Main.main(args); } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTests.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTests.java index 787a4160d..2fbe19b44 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTests.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTests.java @@ -17,10 +17,6 @@ import java.io.File; import org.aspectj.util.FileUtil; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - public class AjdocTests {//extends TestCase { public static File ASPECTJRT_PATH; diff --git a/asm/src/main/java/org/aspectj/asm/AsmManager.java b/asm/src/main/java/org/aspectj/asm/AsmManager.java index dc766eb7f..eaf728296 100644 --- a/asm/src/main/java/org/aspectj/asm/AsmManager.java +++ b/asm/src/main/java/org/aspectj/asm/AsmManager.java @@ -30,7 +30,6 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -155,7 +154,7 @@ public class AsmManager implements IStructureModel { return null; } else { IProgramElement fileNode = node; - ArrayList<IProgramElement> peNodes = new ArrayList<>(); + List<IProgramElement> peNodes = new ArrayList<>(); getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); for (IProgramElement peNode : peNodes) { List<IProgramElement> entries = new ArrayList<>(); diff --git a/asm/src/main/java/org/aspectj/asm/IHierarchy.java b/asm/src/main/java/org/aspectj/asm/IHierarchy.java index 6674cdaea..80ed2b551 100644 --- a/asm/src/main/java/org/aspectj/asm/IHierarchy.java +++ b/asm/src/main/java/org/aspectj/asm/IHierarchy.java @@ -39,7 +39,11 @@ public interface IHierarchy extends Serializable { public boolean removeFromFileMap(String canonicalFilePath); - public void setFileMap(HashMap<String, IProgramElement> fileMap); + public void setFileMap(Map<String, IProgramElement> fileMap); + + public default void setFileMap(HashMap<String, IProgramElement> fileMap) { + setFileMap((Map<String, IProgramElement>) fileMap); + } public Object findInFileMap(Object key); diff --git a/asm/src/main/java/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/main/java/org/aspectj/asm/internal/AspectJElementHierarchy.java index 869affd91..c524c554a 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/AspectJElementHierarchy.java +++ b/asm/src/main/java/org/aspectj/asm/internal/AspectJElementHierarchy.java @@ -96,7 +96,7 @@ public class AspectJElementHierarchy implements IHierarchy { return fileMap.remove(canonicalFilePath) != null; } - public void setFileMap(HashMap<String, IProgramElement> fileMap) { + public void setFileMap(Map<String, IProgramElement> fileMap) { this.fileMap = fileMap; } diff --git a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java index 53818534a..9371211e5 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java +++ b/asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java @@ -11,7 +11,6 @@ package org.aspectj.asm.internal; import java.io.File; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/asm/src/main/java/org/aspectj/asm/internal/RelationshipMap.java b/asm/src/main/java/org/aspectj/asm/internal/RelationshipMap.java index 5a5e18b46..a9bca8a1d 100644 --- a/asm/src/main/java/org/aspectj/asm/internal/RelationshipMap.java +++ b/asm/src/main/java/org/aspectj/asm/internal/RelationshipMap.java @@ -15,7 +15,6 @@ package org.aspectj.asm.internal; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Set; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java index dd1097ff0..014ad558d 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/JavaClass.java @@ -60,12 +60,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.StringTokenizer; +import java.util.*; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; @@ -746,7 +741,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) { vec.add(clazz); } - return vec.toArray(new JavaClass[vec.size()]); + return vec.toArray(new JavaClass[0]); } /** @@ -791,9 +786,7 @@ public class JavaClass extends Modifiers implements Cloneable, Node { } } - for (JavaClass anInterface : interfaces) { - queue.add(anInterface); - } + Collections.addAll(queue, interfaces); } return interfaceList; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java index e18174410..b4734ee92 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java @@ -16,7 +16,6 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.classfile.Attribute; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java index 943b77f6e..03c7c716b 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/ClassGen.java @@ -196,7 +196,7 @@ public class ClassGen extends Modifiers implements Cloneable { ConstantPool cp = this.cpool.getFinalConstantPool(); return new JavaClass(classnameIndex, superclassnameIndex, filename, major, minor, modifiers, cp, interfaces, fields, - methods, attributes.toArray(new Attribute[attributes.size()]));// OPTIMIZE avoid toArray()? + methods, attributes.toArray(new Attribute[0]));// OPTIMIZE avoid toArray()? } public void addInterface(String name) { @@ -509,7 +509,7 @@ public class ClassGen extends Modifiers implements Cloneable { relevantFields.add(field); } } - Collections.sort(relevantFields, new FieldComparator()); + relevantFields.sort(new FieldComparator()); int relevantFlags = Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED | Constants.ACC_STATIC | Constants.ACC_FINAL | Constants.ACC_VOLATILE | Constants.ACC_TRANSIENT; for (Field f : relevantFields) { @@ -534,8 +534,8 @@ public class ClassGen extends Modifiers implements Cloneable { relevantMethods.add(m); } } - Collections.sort(relevantCtors, new ConstructorComparator()); - Collections.sort(relevantMethods, new MethodComparator()); + relevantCtors.sort(new ConstructorComparator()); + relevantMethods.sort(new MethodComparator()); // 5. If a class initializer exists, write out the following: // 1. The name of the method, <clinit>. diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java index 086f276ee..454b74203 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGen.java @@ -54,7 +54,6 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.Constants; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java index c8e1fe2fb..5b4256685 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java @@ -76,8 +76,8 @@ public abstract class FieldGenOrMethodGen extends Modifiers { protected String name; protected Type type; protected ConstantPool cp; - private ArrayList<Attribute> attributeList = new ArrayList<>(); - protected ArrayList<AnnotationGen> annotationList = new ArrayList<>(); + private List<Attribute> attributeList = new ArrayList<>(); + protected List<AnnotationGen> annotationList = new ArrayList<>(); protected FieldGenOrMethodGen() { } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java index c5c244869..8c9c65ab7 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionHandle.java @@ -170,8 +170,7 @@ public class InstructionHandle implements java.io.Serializable { } public Set<InstructionTargeter> getTargetersCopy() { - Set<InstructionTargeter> copy = new HashSet<>(); - copy.addAll(targeters); + Set<InstructionTargeter> copy = new HashSet<>(targeters); return copy; } diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java index 156adf0ad..7938218bc 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/InstructionList.java @@ -58,10 +58,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; +import java.util.*; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Constant; @@ -690,7 +687,7 @@ public class InstructionList implements Serializable { return; } - ArrayList<InstructionHandle> target_vec = new ArrayList<>(); + List<InstructionHandle> target_vec = new ArrayList<>(); for (InstructionHandle ih = first; ih != null; ih = ih.next) { ih.getInstruction().dispose(); // e.g. BranchInstructions release their targets @@ -1003,7 +1000,7 @@ public class InstructionList implements Serializable { */ public Instruction[] getInstructions() { ByteSequence bytes = new ByteSequence(getByteCode()); - ArrayList<Instruction> instructions = new ArrayList<>(); + List<Instruction> instructions = new ArrayList<>(); try { while (bytes.available() > 0) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java index cf8c06834..453fe7c1f 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/generic/MethodGen.java @@ -54,11 +54,7 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; +import java.util.*; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; @@ -103,11 +99,11 @@ public class MethodGen extends FieldGenOrMethodGen { private int highestLineNumber = 0; - private ArrayList<LocalVariableGen> localVariablesList = new ArrayList<>(); - private ArrayList<LineNumberGen> lineNumbersList = new ArrayList<>(); + private List<LocalVariableGen> localVariablesList = new ArrayList<>(); + private List<LineNumberGen> lineNumbersList = new ArrayList<>(); private ArrayList<CodeExceptionGen> exceptionsList = new ArrayList<>(); private ArrayList<String> exceptionsThrown = new ArrayList<>(); - private ArrayList<Attribute> codeAttributesList = new ArrayList<>(); + private List<Attribute> codeAttributesList = new ArrayList<>(); private List<AnnotationGen>[] param_annotations; // Array of lists containing AnnotationGen objects private boolean hasParameterAnnotations = false; private boolean haveUnpackedParameterAnnotations = false; @@ -934,7 +930,7 @@ public class MethodGen extends FieldGenOrMethodGen { static final class BranchStack { Stack<BranchTarget> branchTargets = new Stack<>(); - Hashtable<InstructionHandle, BranchTarget> visitedTargets = new Hashtable<>(); + Map<InstructionHandle, BranchTarget> visitedTargets = new Hashtable<>(); public void push(InstructionHandle target, int stackDepth) { if (visited(target)) { diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java index 179800540..678abb1dc 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java @@ -69,11 +69,7 @@ import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.StringTokenizer; +import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -106,7 +102,7 @@ public class ClassPath implements Serializable { public ClassPath(String class_path) { this.class_path = class_path; - ArrayList<PathEntry> vec = new ArrayList<>(); + List<PathEntry> vec = new ArrayList<>(); for (StringTokenizer tok = new StringTokenizer(class_path, System.getProperty("path.separator")); tok .hasMoreTokens();) { @@ -167,7 +163,7 @@ public class ClassPath implements Serializable { return false; } - private static final void getPathComponents(String path, ArrayList<String> list) { + private static final void getPathComponents(String path, List<String> list) { if (path != null) { StringTokenizer tok = new StringTokenizer(path, File.pathSeparator); diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java index a7689b108..e2e5f38bb 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java @@ -62,7 +62,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.AbstractMap; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -211,11 +210,7 @@ public class NonCachingClassLoaderRepository implements Repository { */ public JavaClass findClass(String className) { synchronized (loadedClasses) { - if (loadedClasses.containsKey(className)) { - return loadedClasses.get(className); - } else { - return null; - } + return loadedClasses.getOrDefault(className, null); } } diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java index d684144eb..84f9d9532 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java @@ -97,7 +97,7 @@ public class AnnotationGenTest extends BcelTestCase { // Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) AnnotationGen a = new AnnotationGen(t, elements, true, cp); - Vector<AnnotationGen> v = new Vector<>(); + List<AnnotationGen> v = new Vector<>(); v.add(a); Collection<RuntimeAnnos> attributes = Utility.getAnnotationAttributes(cp, v); boolean foundRV = false; @@ -113,7 +113,7 @@ public class AnnotationGenTest extends BcelTestCase { // Build a RIV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) AnnotationGen a2 = new AnnotationGen(t, elements, false, cp); - Vector<AnnotationGen> v2 = new Vector<>(); + List<AnnotationGen> v2 = new Vector<>(); v2.add(a2); Collection<RuntimeAnnos> attributes2 = Utility.getAnnotationAttributes(cp, v2); boolean foundRIV = false; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java index 038a1381e..54969f490 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java @@ -14,7 +14,6 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.io.IOException; -import java.util.Iterator; import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.JavaClass; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java index 45fd47c7b..00a300b61 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java @@ -11,7 +11,6 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.Constants; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java index 255dc77ff..c97e12678 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java @@ -12,6 +12,7 @@ package org.aspectj.apache.bcel.classfile.tests; import java.util.ArrayList; +import java.util.List; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; @@ -415,7 +416,7 @@ public class GenericSignatureParsingTest extends BcelTestCase { * @return Array of argument types */ public static final String[] methodSignatureArgumentTypes(String signature,boolean chopit) throws ClassFormatException { - ArrayList<String> vec = new ArrayList<>(); + List<String> vec = new ArrayList<>(); int index; String[] types; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java index 8876813d2..26f877cce 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java @@ -14,7 +14,6 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.io.IOException; -import java.util.Iterator; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java index a4926caa5..5fe956790 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java @@ -15,7 +15,6 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.classfile.Attribute; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java index eb594974c..be0b2fb30 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java @@ -14,7 +14,6 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.io.IOException; -import java.util.Iterator; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; diff --git a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java index bf41bb3c1..23c46ac25 100644 --- a/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java +++ b/bcel-builder/src/test/java/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java @@ -14,7 +14,6 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.io.IOException; -import java.util.Iterator; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageHandler.java b/bridge/src/main/java/org/aspectj/bridge/MessageHandler.java index 23c2ef3b2..95bcf029d 100644 --- a/bridge/src/main/java/org/aspectj/bridge/MessageHandler.java +++ b/bridge/src/main/java/org/aspectj/bridge/MessageHandler.java @@ -31,7 +31,7 @@ public class MessageHandler implements IMessageHolder { /** messages accumulated */ protected final ArrayList<IMessage> messages; /** kinds of messages to be ignored */ - protected final ArrayList<IMessage.Kind> ignoring; + protected final List<IMessage.Kind> ignoring; /** result of handleMessage(..) for messages not accumulated (ignored) */ protected boolean handleMessageResult; /** listener which can halt processing by returning true */ diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java index d55ac3c3b..0ebe113e0 100644 --- a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java +++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java @@ -409,7 +409,7 @@ public class MessageUtil { if (null == kind) { return messages; } - ArrayList<IMessage> result = new ArrayList<>(); + List<IMessage> result = new ArrayList<>(); for (IMessage message : messages) { if (kind == message.getKind()) { result.add(message); diff --git a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java index 2ae13a279..e1ea09a99 100644 --- a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java +++ b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java @@ -130,7 +130,7 @@ public class CompilationAndWeavingContext { * Returns a string description of what the compiler/weaver is currently doing */ public static String getCurrentContext() { - Stack<ContextStackEntry> contextStack = getContextStack(); + Iterable<ContextStackEntry> contextStack = getContextStack(); Stack<String> explanationStack = new Stack<>(); for (ContextStackEntry entry : contextStack) { Object data = entry.getData(); diff --git a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java index d3bd73be6..7ef2eafb4 100644 --- a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java +++ b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java @@ -17,7 +17,6 @@ import java.io.File; import java.util.Arrays; import java.util.BitSet; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java index 809ac1cbb..a67872e8c 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringBufferInputStream; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.zip.CRC32; import java.util.zip.ZipEntry; diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index 91506e439..31ed76201 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index ed64e74e0..e343c9d48 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -469,8 +469,7 @@ class HeaderInfo { this.lastLine = lastLine; this.file = file; this.hasLicense = hasLicense; - List<String> newYears = new ArrayList<>(); - newYears.addAll(years); + List<String> newYears = new ArrayList<>(years); Collections.sort(newYears); this.years = Collections.unmodifiableList(newYears); if ((null == file) || !file.canWrite()) { @@ -655,7 +654,7 @@ class Header { * * @return true if this line has end-of-comment */ - private static boolean checkLine(String line, ArrayList<String> years) { + private static boolean checkLine(String line, List<String> years) { if ((null == line) || (0 == line.length())) { return false; } diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java index ac13870c8..b43578dd3 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java @@ -19,7 +19,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Properties; @@ -181,7 +180,7 @@ public abstract class Builder { private final File tempDir; - private final ArrayList tempFiles; + private final List tempFiles; private final boolean useEclipseCompiles; @@ -275,7 +274,7 @@ public abstract class Builder { return buildProduct(buildSpec); } Result result = specifyResultFor(buildSpec); - ArrayList<String> errors = new ArrayList<>(); + List<String> errors = new ArrayList<>(); try { return buildAll(result, errors); } finally { @@ -340,7 +339,7 @@ public abstract class Builder { */ protected final boolean buildAll(Result result, List<String> errors) { Result[] buildList = skipUptodate(getAntecedantResults(result)); - ArrayList<String> doneList = new ArrayList<>(); + List<String> doneList = new ArrayList<>(); if ((null != buildList) && (0 < buildList.length)) { if (isLogging()) { handler.log("modules to build: " + Arrays.asList(buildList)); @@ -525,7 +524,7 @@ public abstract class Builder { } protected final boolean buildProductModule(ProductModule module) { - ArrayList<String> errors = new ArrayList<>(); + List<String> errors = new ArrayList<>(); try { Kind productKind = Result.kind(Result.NORMAL, Result.ASSEMBLE); Result result = module.module.getResult(productKind); @@ -543,7 +542,7 @@ public abstract class Builder { * deliverables. */ protected ProductModule[] discoverModules(File productDir, Modules modules) { - final ArrayList<File> found = new ArrayList<>(); + final List<File> found = new ArrayList<>(); FileFilter filter = new FileFilter() {// empty jar files public boolean accept(File file) { if ((null != file) && file.canRead() diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Module.java b/build/src/main/java/org/aspectj/internal/tools/build/Module.java index 3f34b3f5e..9d10e4743 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Module.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Module.java @@ -69,7 +69,7 @@ public class Module { /** @return all source files under srcDir */ private static Iterator<File> sourceFiles(File srcDir) { - ArrayList<File> result = new ArrayList<>(); + List<File> result = new ArrayList<>(); sourceFiles(srcDir, result); return result.iterator(); } diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Result.java b/build/src/main/java/org/aspectj/internal/tools/build/Result.java index 563a6932e..22b92c8af 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Result.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Result.java @@ -217,7 +217,7 @@ public class Result { /** @return List (File) of jar's required */ public List<File> findJarRequirements() { - ArrayList<File> result = new ArrayList<>(); + List<File> result = new ArrayList<>(); Module.doFindJarRequirements(this, result); return result; } diff --git a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java index ca041b33d..2864bb92f 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java @@ -32,9 +32,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Date; -import java.util.Iterator; import java.util.List; -import java.util.ListIterator; /** * This gathers sample code delimited with [START..END]-SAMPLE @@ -221,7 +219,7 @@ public class SampleGatherer { source, startLine, endLine, - flags.toArray(new String[flags.size()])); + flags.toArray(new String[0])); sink.addSample(sample); // back to seeking start @@ -419,9 +417,8 @@ class Samples { } List<Sample> getSortedSamples(Comparator<Sample> comparer) { - ArrayList<Sample> result = new ArrayList<>(); - result.addAll(samples); - Collections.sort(result, comparer); + List<Sample> result = new ArrayList<>(samples); + result.sort(comparer); return result; } } @@ -978,7 +975,7 @@ class SampleUtil { } next = anchorName.substring(start); result.add(next); - return result.toArray(new String[result.size()]); + return result.toArray(new String[0]); } /** * Replace literals with literals in source string diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Util.java b/build/src/main/java/org/aspectj/internal/tools/build/Util.java index dd393ce45..cd7d6623f 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Util.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Util.java @@ -357,7 +357,7 @@ public class Util { /** unmodifiable list of all valid OSGIBundle Name's */ public static final List<Name> NAMES; static { - ArrayList<Name> names = new ArrayList<>(); + List<Name> names = new ArrayList<>(); names.add(BUNDLE_NAME); names.add(BUNDLE_SYMBOLIC_NAME); names.add(BUNDLE_VERSION); diff --git a/build/src/test/java/org/aspectj/build/BuildModuleTests.java b/build/src/test/java/org/aspectj/build/BuildModuleTests.java index f4aaa5708..46f5b15a0 100644 --- a/build/src/test/java/org/aspectj/build/BuildModuleTests.java +++ b/build/src/test/java/org/aspectj/build/BuildModuleTests.java @@ -225,7 +225,7 @@ public class BuildModuleTests extends TestCase { */ static class UnknownFileCheck implements FileFilter { private static final UnknownFileCheck SINGLETON = new UnknownFileCheck(); - private static final ArrayList<String> STATIC_ERRORS = new ArrayList<>(); + private static final List<String> STATIC_ERRORS = new ArrayList<>(); // Builder.BINARY_SOURCE_PATTERN and Builder.RESOURCE_PATTERN public static final List<String> KNOWN_SUFFIXES; diff --git a/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java b/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java index 7693ddb11..33dac2a0a 100644 --- a/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java +++ b/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java @@ -16,10 +16,7 @@ package org.aspectj.internal.build; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.Iterator; +import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; @@ -80,7 +77,7 @@ public class BuildModuleTest extends TestCase { } } - ArrayList<File> tempFiles = new ArrayList<>(); + List<File> tempFiles = new ArrayList<>(); private File jarDir; private boolean deleteJars; boolean building; // must be enabled for tests to run @@ -343,7 +340,7 @@ public class BuildModuleTest extends TestCase { try { zipFile = new ZipFile(weaverAllJar); Enumeration e = zipFile.entries(); - ArrayList<String> entryNames = new ArrayList<>(); + List<String> entryNames = new ArrayList<>(); while (e.hasMoreElements()) { ZipEntry entry = (ZipEntry) e.nextElement(); String name = entry.getName(); diff --git a/build/src/test/java/org/aspectj/internal/build/ModulesTest.java b/build/src/test/java/org/aspectj/internal/build/ModulesTest.java index 494084e0c..ce6d77d78 100644 --- a/build/src/test/java/org/aspectj/internal/build/ModulesTest.java +++ b/build/src/test/java/org/aspectj/internal/build/ModulesTest.java @@ -18,7 +18,6 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import junit.framework.TestCase; @@ -72,7 +71,7 @@ public class ModulesTest extends TestCase { } } - ArrayList<File> tempFiles = new ArrayList<>(); + List<File> tempFiles = new ArrayList<>(); public ModulesTest(String name) { super(name); @@ -101,7 +100,7 @@ public class ModulesTest extends TestCase { } public void testAllModulesCreation() { - ArrayList<Module> badModules = new ArrayList<>(); + List<Module> badModules = new ArrayList<>(); for (String name: MODULE_NAMES) { File dir = new File(BASE_DIR, name); if (dir.isDirectory()) { diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java index 57db3092f..501cfe75b 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Aj.java @@ -17,7 +17,6 @@ import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java index fcc89ac75..aa228804c 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -910,8 +909,7 @@ public class ConcreteAspectCodeGen { } // Time to construct the method itself: - LazyMethodGen advice = new LazyMethodGen(Modifier.PUBLIC, returnType, adviceName, paramTypes.toArray(new Type[paramTypes - .size()]), EMPTY_STRINGS, cg); + LazyMethodGen advice = new LazyMethodGen(Modifier.PUBLIC, returnType, adviceName, paramTypes.toArray(new Type[0]), EMPTY_STRINGS, cg); InstructionList adviceBody = advice.getBody(); diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java index 31b125610..cb5f00f09 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/Options.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.loadtime; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -114,7 +114,6 @@ if $mingw ; then M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -212,7 +211,11 @@ else if [ "$MVNW_VERBOSE" = true ]; then echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi while IFS="=" read key value; do case "$key" in (wrapperUrl) jarUrl="$value"; break ;; esac @@ -221,22 +224,38 @@ else echo "Downloading from: $jarUrl" fi wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi if command -v wget > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found wget ... using wget" fi - wget "$jarUrl" -O "$wrapperJarPath" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi elif command -v curl > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found curl ... using curl" fi - curl -o "$wrapperJarPath" "$jarUrl" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + else if [ "$MVNW_VERBOSE" = true ]; then echo "Falling back to using Java to download" fi javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi if [ -e "$javaClass" ]; then if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then if [ "$MVNW_VERBOSE" = true ]; then @@ -277,6 +296,11 @@ if $cygwin; then MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ diff --git a/mvnw.cmd b/mvnw.cmd index 48363fa60..86115719e 100755..100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,161 +1,182 @@ -@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM set title of command window
-title %0
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
-FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
- IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
-)
-
-@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
-@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
-if exist %WRAPPER_JAR% (
- echo Found %WRAPPER_JAR%
-) else (
- echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
- powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
- echo Finished downloading %WRAPPER_JAR%
-)
-@REM End of extension
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
+@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java index 07332990f..177f53145 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -19,7 +19,6 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; @@ -152,8 +151,7 @@ public class BuildArgParser extends Main { boolean incrementalMode = buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode(); - List<File> xmlfileList = new ArrayList<>(); - xmlfileList.addAll(parser.getXmlFiles()); + List<File> xmlfileList = new ArrayList<>(parser.getXmlFiles()); List<File> fileList = new ArrayList<>(); List<File> files = parser.getFiles(); @@ -177,7 +175,7 @@ public class BuildArgParser extends Main { // javaArgList.add("-bootclasspath"); // javaArgList.add(parser.bootclasspath == null ? System.getProperty("user.dir") : parser.bootclasspath); javaArgList.addAll(parser.getUnparsedArgs()); - super.configure(javaArgList.toArray(new String[javaArgList.size()])); + super.configure(javaArgList.toArray(new String[0])); if (parser.getModuleInfoArgument() != null) { IModule moduleDesc = super.getModuleDesc(parser.getModuleInfoArgument()); @@ -904,7 +902,7 @@ public class BuildArgParser extends Main { unparsedArgs.add(nextArg.getValue()); } - private int indexOf(LinkedList<Arg> args, String arg) { + private int indexOf(Iterable<Arg> args, String arg) { int index = 0; for (Arg argument : args) { if (arg.equals(argument.getValue())) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java index e58b57ea7..664260cb5 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java @@ -13,7 +13,6 @@ package org.aspectj.ajdt.internal.compiler; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java index 5c2e4d2c7..3c0f095f4 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java @@ -14,7 +14,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java index 77872416a..c14539c8d 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ClassFileBasedByteCodeProvider.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.aspectj.ajdt.internal.compiler; -import java.util.Iterator; - import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.weaver.bcel.UnwovenClassFile; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index 68fc6f74f..a8be5eee7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -172,11 +172,7 @@ public class AccessForInlineVisitor extends ASTVisitor { } // Avoid repeatedly building ResolvedMembers by using info on any done previously in this visitor - Map<FieldBinding, ResolvedMember> alreadyResolvedMembers = alreadyProcessedReceivers.get(receiverType); - if (alreadyResolvedMembers == null) { - alreadyResolvedMembers = new HashMap<>(); - alreadyProcessedReceivers.put(receiverType, alreadyResolvedMembers); - } + Map<FieldBinding, ResolvedMember> alreadyResolvedMembers = alreadyProcessedReceivers.computeIfAbsent(receiverType, k -> new HashMap<>()); ResolvedMember m = alreadyResolvedMembers.get(binding); if (m == null) { m = world.makeResolvedMember(binding, receiverType); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java index 977c6efa6..f151fd21b 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java @@ -24,7 +24,6 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.weaver.AjcMemberMaker; public class AspectClinit extends Clinit { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index 777de27e4..f81e5bf95 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -14,7 +14,6 @@ package org.aspectj.ajdt.internal.compiler.ast; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java index 369e84c51..04693fd86 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java @@ -112,7 +112,7 @@ public class AstUtil { } public static void setStatements(MethodDeclaration ret, List statements) { - ret.statements = (Statement[]) statements.toArray(new Statement[statements.size()]); + ret.statements = (Statement[]) statements.toArray(new Statement[0]); } public static SingleNameReference makeLocalVariableReference(LocalVariableBinding binding) { @@ -217,7 +217,7 @@ public class AstUtil { } public static List getAjSyntheticAttribute() { - ArrayList ret = new ArrayList(1); + List ret = new ArrayList(1); ret.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); return ret; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java index a2448f314..758f99eb5 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java @@ -19,7 +19,6 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo; -import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; import org.aspectj.weaver.patterns.DeclareAnnotation; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IfPseudoToken.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IfPseudoToken.java index 7d7842c6d..bd8c5d705 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IfPseudoToken.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IfPseudoToken.java @@ -34,7 +34,6 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; -import org.aspectj.weaver.BCException; import org.aspectj.weaver.Member; import org.aspectj.weaver.ResolvedMemberImpl; import org.aspectj.weaver.UnresolvedType; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/KnownMessageSend.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/KnownMessageSend.java index 20bbef57a..5869d31ad 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/KnownMessageSend.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/KnownMessageSend.java @@ -14,7 +14,6 @@ package org.aspectj.ajdt.internal.compiler.ast; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; -import org.aspectj.org.eclipse.jdt.internal.compiler.impl.Constant; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java index 365f56940..f714ffe55 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java @@ -13,7 +13,6 @@ package org.aspectj.ajdt.internal.compiler.ast; import java.lang.reflect.Modifier; -import java.util.Iterator; import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.ajdt.internal.core.builder.EclipseSourceContext; @@ -26,11 +25,9 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclarat import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index d79755dde..beea71dc9 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -13,14 +13,7 @@ package org.aspectj.ajdt.internal.compiler.lookup; import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import org.aspectj.ajdt.internal.compiler.CommonPrinter; import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration; @@ -254,13 +247,10 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { CompilationUnitScope cus = units[i].scope; SourceTypeBinding[] stbs = cus.topLevelTypes; - for (SourceTypeBinding stb : stbs) { - typesToProcess.add(stb); - } + Collections.addAll(typesToProcess, stbs); } - List<SourceTypeBinding> stb2 = new ArrayList<>(); - stb2.addAll(typesToProcess); + List<SourceTypeBinding> stb2 = new ArrayList<>(typesToProcess); while (typesToProcess.size() > 0) { // A side effect of weaveIntertypes() is that the processed type is removed from the collection diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java index 06191629f..74805b9c6 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseScope.java @@ -197,9 +197,9 @@ public class EclipseScope implements IScope { importedNamesList.add(world.fromBinding(topType).getName()); } - importedNames = importedNamesList.toArray(new String[importedNamesList.size()]); + importedNames = importedNamesList.toArray(new String[0]); - importedPrefixes = importedPrefixesList.toArray(new String[importedPrefixesList.size()]); + importedPrefixes = importedPrefixesList.toArray(new String[0]); } private void addClassAndParentsToPrefixes(ReferenceBinding binding, List<String> importedPrefixesList) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index 1941ad630..4731a86ed 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -349,9 +349,9 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { declaredFields.add(factory.makeResolvedMember(f)); } - this.declaredPointcuts = declaredPointcuts.toArray(new ResolvedPointcutDefinition[declaredPointcuts.size()]); - this.declaredMethods = declaredMethods.toArray(new ResolvedMember[declaredMethods.size()]); - this.declaredFields = declaredFields.toArray(new ResolvedMember[declaredFields.size()]); + this.declaredPointcuts = declaredPointcuts.toArray(new ResolvedPointcutDefinition[0]); + this.declaredMethods = declaredMethods.toArray(new ResolvedMember[0]); + this.declaredFields = declaredFields.toArray(new ResolvedMember[0]); } private final static char[] valuesCharArray = "values".toCharArray(); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java index 80ffe4222..1953265c8 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java @@ -270,7 +270,7 @@ public class InterTypeMemberFinder implements IMemberFinder { if (ret.isEmpty()) { return Binding.NO_METHODS; } - return ret.toArray(new MethodBinding[ret.size()]); + return ret.toArray(new MethodBinding[0]); } private void addPublicITDSFrom(SourceTypeBinding anInterface, List<MethodBinding> accumulator) { @@ -328,7 +328,7 @@ public class InterTypeMemberFinder implements IMemberFinder { // System.err.println("got methods: " + ret + " on " + sourceTypeBinding); - return ret.toArray(new MethodBinding[ret.size()]); + return ret.toArray(new MethodBinding[0]); } @Override diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java index a361cd881..0885475b3 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java @@ -14,7 +14,6 @@ package org.aspectj.ajdt.internal.compiler.lookup; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java index 894492bf3..2730b5b58 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PushinCollector.java @@ -253,20 +253,12 @@ public class PushinCollector { // can be null for binary weave (there is no source method) return; } - List<AbstractMethodDeclaration> amds = newDeclarations.get(sourceType); - if (amds == null) { - amds = new ArrayList<>(); - newDeclarations.put(sourceType, amds); - } + List<AbstractMethodDeclaration> amds = newDeclarations.computeIfAbsent(sourceType, k -> new ArrayList<>()); amds.add(sourceMethod); } public void tagAsMunged(SourceTypeBinding sourceType, String annotationString) { - List<String> annos = additionalAnnotations.get(sourceType); - if (annos == null) { - annos = new ArrayList<>(); - additionalAnnotations.put(sourceType, annos); - } + List<String> annos = additionalAnnotations.computeIfAbsent(sourceType, k -> new ArrayList<>()); annos.add(annotationString); } @@ -320,11 +312,7 @@ public class PushinCollector { public void tagAsMunged(SourceTypeBinding sourceType, TypePattern typePattern) { if (typePattern instanceof ExactTypePattern) { - List<ExactTypePattern> annos = additionalParents.get(sourceType); - if (annos == null) { - annos = new ArrayList<>(); - additionalParents.put(sourceType, annos); - } + List<ExactTypePattern> annos = additionalParents.computeIfAbsent(sourceType, k -> new ArrayList<>()); annos.add((ExactTypePattern) typePattern); } } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index c42a503c6..f563d913b 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -17,7 +17,6 @@ import java.io.StringWriter; import java.lang.reflect.Modifier; import java.util.Collection; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index cfda72357..35a71fd10 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -69,10 +69,10 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { private List<String> classpath = new ArrayList<>(); private List<String> modulepath = new ArrayList<>(); // Expensive to compute (searching modules, parsing module-info) - private ArrayList<Classpath> modulepathClasspathEntries = null; + private Collection<Classpath> modulepathClasspathEntries = null; private List<String> modulesourcepath = new ArrayList<>(); // Expensive to compute (searching modules, parsing module-info) - private ArrayList<Classpath> modulesourcepathClasspathEntries = null; + private Collection<Classpath> modulesourcepathClasspathEntries = null; private Classpath[] checkedClasspaths = null; private List<String> bootclasspath = new ArrayList<>(); private List<String> cpElementsWithModifiedContents = new ArrayList<>(); @@ -377,8 +377,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { * classpath), and output dir or jar */ public List<String> getFullClasspath() { - List<String> full = new ArrayList<>(); - full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? + List<String> full = new ArrayList<>(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? for (File file: inJars) { full.add(file.getAbsolutePath()); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 9510bec56..fb086e9f3 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java index 84319600c..af397b170 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Stack; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java index f81d1d937..a344b7f04 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java @@ -17,7 +17,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.Collection; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java index 32794ef44..1855c46d8 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java @@ -13,7 +13,6 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java index 5333ec18f..429e0f5b7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java @@ -13,7 +13,6 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; /** diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java index de6afab25..e94b43f0e 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java @@ -11,7 +11,6 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; /** diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java index 88558fed0..2f3713148 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java @@ -141,7 +141,7 @@ public class Main { } private static boolean flagInArgs(String flag, String[] args) { - return ((null != args) && (Arrays.asList(args).indexOf(flag) != -1)); + return ((null != args) && (Arrays.asList(args).contains(flag))); } /** diff --git a/org.aspectj.ajdt.core/src/test/java/RunWeaveTests.java b/org.aspectj.ajdt.core/src/test/java/RunWeaveTests.java index e54ab44e2..ad68e64d5 100644 --- a/org.aspectj.ajdt.core/src/test/java/RunWeaveTests.java +++ b/org.aspectj.ajdt.core/src/test/java/RunWeaveTests.java @@ -51,44 +51,30 @@ public class RunWeaveTests { WeaveTest.main( split(SMALL_PROGRAM_ARGS + "-echo -i " + ITERATIONS)); - for (int i = 0; i < ITERATIONS; i++) - times[0][i] = WeaveTest.compileTimes[i]; + System.arraycopy(WeaveTest.compileTimes, 0, times[0], 0, ITERATIONS); - for (int i = 0; i < ITERATIONS; i++) - times[1][i] = WeaveTest.executionFastTimes[i]; - for (int i = 0; i < ITERATIONS; i++) - times[2][i] = WeaveTest.executionMedTimes[i]; - for (int i = 0; i < ITERATIONS; i++) - times[3][i] = WeaveTest.executionSlowTimes[i]; + System.arraycopy(WeaveTest.executionFastTimes, 0, times[1], 0, ITERATIONS); + System.arraycopy(WeaveTest.executionMedTimes, 0, times[2], 0, ITERATIONS); + System.arraycopy(WeaveTest.executionSlowTimes, 0, times[3], 0, ITERATIONS); - for (int i = 0; i < ITERATIONS; i++) - times[4][i] = WeaveTest.getFastTimes[i]; - for (int i = 0; i < ITERATIONS; i++) - times[5][i] = WeaveTest.getMedTimes[i]; - for (int i = 0; i < ITERATIONS; i++) - times[6][i] = WeaveTest.getSlowTimes[i]; + System.arraycopy(WeaveTest.getFastTimes, 0, times[4], 0, ITERATIONS); + System.arraycopy(WeaveTest.getMedTimes, 0, times[5], 0, ITERATIONS); + System.arraycopy(WeaveTest.getSlowTimes, 0, times[6], 0, ITERATIONS); } if (RUN_MED) { WeaveTest.main( split(MEDIUM_PROGRAM_ARGS + "-echo -i " + ITERATIONS)); - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[0][i] = WeaveTest.compileTimes[i - ITERATIONS]; + System.arraycopy(WeaveTest.compileTimes, 0, times[0], ITERATIONS, 2 * ITERATIONS - 3); - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[1][i] = WeaveTest.executionFastTimes[i - ITERATIONS]; - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[2][i] = WeaveTest.executionMedTimes[i - ITERATIONS]; - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[3][i] = WeaveTest.executionSlowTimes[i - ITERATIONS]; + System.arraycopy(WeaveTest.executionFastTimes, 0, times[1], ITERATIONS, 2 * ITERATIONS - 3); + System.arraycopy(WeaveTest.executionMedTimes, 0, times[2], ITERATIONS, 2 * ITERATIONS - 3); + System.arraycopy(WeaveTest.executionSlowTimes, 0, times[3], ITERATIONS, 2 * ITERATIONS - 3); - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[4][i] = WeaveTest.getFastTimes[i - ITERATIONS]; - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[5][i] = WeaveTest.getMedTimes[i - ITERATIONS]; - for (int i = ITERATIONS; i < (2 * ITERATIONS); i++) - times[6][i] = WeaveTest.getSlowTimes[i - ITERATIONS]; + System.arraycopy(WeaveTest.getFastTimes, 0, times[4], ITERATIONS, 2 * ITERATIONS - 3); + System.arraycopy(WeaveTest.getMedTimes, 0, times[5], ITERATIONS, 2 * ITERATIONS - 3); + System.arraycopy(WeaveTest.getSlowTimes, 0, times[6], ITERATIONS, 2 * ITERATIONS - 3); } @@ -96,25 +82,15 @@ public class RunWeaveTests { WeaveTest.main( split(LARGE_PROGRAM_ARGS + "-echo -i " + ITERATIONS)); - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[0][i] = WeaveTest.compileTimes[i - (2 * ITERATIONS)]; + System.arraycopy(WeaveTest.compileTimes, 0, times[0], 2 * ITERATIONS, 3 * ITERATIONS - 6); - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[1][i] = - WeaveTest.executionFastTimes[i - (2 * ITERATIONS)]; - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[2][i] = - WeaveTest.executionMedTimes[i - (2 * ITERATIONS)]; - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[3][i] = - WeaveTest.executionSlowTimes[i - (2 * ITERATIONS)]; + System.arraycopy(WeaveTest.executionFastTimes, 0, times[1], 2 * ITERATIONS, 3 * ITERATIONS - 6); + System.arraycopy(WeaveTest.executionMedTimes, 0, times[2], 2 * ITERATIONS, 3 * ITERATIONS - 6); + System.arraycopy(WeaveTest.executionSlowTimes, 0, times[3], 2 * ITERATIONS, 3 * ITERATIONS - 6); - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[4][i] = WeaveTest.getFastTimes[i - (2 * ITERATIONS)]; - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[5][i] = WeaveTest.getMedTimes[i - (2 * ITERATIONS)]; - for (int i = (2 * ITERATIONS); i < (3 * ITERATIONS); i++) - times[6][i] = WeaveTest.getSlowTimes[i - (2 * ITERATIONS)]; + System.arraycopy(WeaveTest.getFastTimes, 0, times[4], 2 * ITERATIONS, 3 * ITERATIONS - 6); + System.arraycopy(WeaveTest.getMedTimes, 0, times[5], 2 * ITERATIONS, 3 * ITERATIONS - 6); + System.arraycopy(WeaveTest.getSlowTimes, 0, times[6], 2 * ITERATIONS, 3 * ITERATIONS - 6); } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java index 57c2f8e4c..95bd5c4c6 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.List; import java.util.ListIterator; import junit.framework.TestCase; @@ -38,7 +39,7 @@ import org.aspectj.util.FileUtil; */ public class AjdtCommandTestCase extends TestCase { - private ArrayList tempFiles = new ArrayList(); + private List tempFiles = new ArrayList(); private StreamPrintWriter outputWriter = new StreamPrintWriter(new PrintWriter(System.out)); // private AjdtCommand command = new AjdtCommand(); private MessageWriter messageWriter = new MessageWriter(outputWriter, false); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/Constants.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/Constants.java index 3093b84e1..f9078d032 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/Constants.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/Constants.java @@ -10,7 +10,6 @@ package org.aspectj.ajdt.ajc; import java.io.File; import org.aspectj.testing.util.TestUtil; -import junit.framework.*; /** * @author Andy Clement diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java index 99ea9b1d9..a670cad50 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java @@ -18,11 +18,9 @@ import java.util.ArrayList; import java.util.List; import org.aspectj.ajdt.ajc.*; -import org.aspectj.ajdt.ajc.AjdtCommand; import org.aspectj.bridge.ICommand; //import org.aspectj.bridge.IMessage; import org.aspectj.bridge.MessageHandler; -import org.aspectj.util.LangUtil; /** * @author hugunin @@ -116,13 +114,14 @@ public class BasicCommandTestCase extends CommandTestCase { args.add(getSandboxName()); args.add("-classpath"); - args.add(getRuntimeClasspath() + File.pathSeparator +
"../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar"); + args.add(getRuntimeClasspath() + File.pathSeparator + + "../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar"); args.add(Constants.TESTDATA_PATH + "/src1/ThisAndModifiers.java"); ICommand command = new AjdtCommand(); MessageHandler myHandler = new MessageHandler(); //myHandler.setInterceptor(org.aspectj.tools.ajc.Main.MessagePrinter.TERSE); - /*boolean result = */command.runCommand((String[])args.toArray(new String[args.size()]), myHandler); + /*boolean result = */command.runCommand((String[])args.toArray(new String[0]), myHandler); //System.err.println("messages: " + Arrays.asList(myHandler.getMessages(IMessage.INFO, true))); // DON'T yet have a way of testing that we actually got a particular info message @@ -142,7 +141,7 @@ public class BasicCommandTestCase extends CommandTestCase { ICommand command = new AjdtCommand(); MessageHandler myHandler = new MessageHandler(); myHandler.setInterceptor(org.aspectj.tools.ajc.Main.MessagePrinter.TERSE); - /*boolean result = */command.runCommand((String[])args.toArray(new String[args.size()]), myHandler); + /*boolean result = */command.runCommand((String[])args.toArray(new String[0]), myHandler); assertEquals("error for org.aspectj.lang.JoinPoint not found", 1, myHandler.getErrors().length); } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java index 983ff62d5..4fd1b50c6 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; import org.aspectj.ajdt.ajc.Constants; -import org.aspectj.testing.util.TestUtil; public class BcweaverJarMaker { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java index 1a3cc12b2..78b82d223 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java @@ -14,10 +14,7 @@ package org.aspectj.ajdt.internal.compiler.batch; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; import junit.framework.TestCase; @@ -29,7 +26,6 @@ import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.IMessageHolder; import org.aspectj.bridge.MessageHandler; import org.aspectj.testing.util.TestUtil; -import org.aspectj.tools.ajc.Ajc; import org.aspectj.util.LangUtil; import org.aspectj.weaver.bcel.LazyClassGen; @@ -74,9 +70,7 @@ public abstract class CommandTestCase extends TestCase { args.add("-g"); // XXX need this to get sourcefile and line numbers, shouldn't - for (String extraArg : extraArgs) { - args.add(extraArg); - } + Collections.addAll(args, extraArgs); args.add(Constants.TESTDATA_PATH + "/" + source); @@ -117,7 +111,7 @@ public abstract class CommandTestCase extends TestCase { ICommand command = new AjdtCommand(); MessageHandler myHandler = new MessageHandler(); myHandler.setInterceptor(org.aspectj.tools.ajc.Main.MessagePrinter.TERSE); - boolean result = command.runCommand((String[]) args.toArray(new String[args.size()]), myHandler); + boolean result = command.runCommand((String[]) args.toArray(new String[0]), myHandler); System.out.println("result: " + result); // System.out.println("errors: " + Arrays.asList(myHandler.getErrors())); // System.out.println("warnings: " + Arrays.asList(myHandler.getWarnings())); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java index 355267b0f..0d84dfc8f 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java @@ -84,7 +84,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? if (null == targetClasses) { return false; } - final ArrayList<File> files = new ArrayList<>(); + final List<File> files = new ArrayList<>(); final FileFilter collector = new FileFilter() { @Override public boolean accept(File file) { @@ -94,7 +94,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? final ICommand compiler = ReflectionFactory.makeCommand(cname, handler); - ArrayList recompiled = null; + List recompiled = null; boolean result = true; final String toSuffix = ".java"; @@ -121,8 +121,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? List safeFiles = Collections.unmodifiableList(files); log("Compiling ", safeFiles, handler); if (1 == i) { - ArrayList<String> argList = new ArrayList<>(); - argList.addAll(getBaseArgs(targetSrc, targetClasses)); + ArrayList<String> argList = new ArrayList<>(getBaseArgs(targetSrc, targetClasses)); File[] fra = (File[]) safeFiles.toArray(new File[0]); // sigh argList.addAll( @@ -258,7 +257,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? List<String> normalizeFilenames(String[] ra) { // XXX util - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); if (null != ra) { for (String s : ra) { result.add(normalizeFilename(s)); @@ -272,7 +271,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests? /** @param list the List of File */ List<String> normalizeFilenames(List<File> list) { // XXX util - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); for (File file: list) { // for (Iterator<?> iter = list.iterator(); iter.hasNext();) { result.add(normalizeFilename(file.getPath())); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java index de8960e73..b38e8166c 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java @@ -421,7 +421,7 @@ public class ASTVisitorTest extends TestCase { private void checkJLS3(String source, String expectedOutput) { ASTParser parser = ASTParser.newParser(AST.JLS3); - HashMap<String,String> options = new HashMap<>(); + Map<String,String> options = new HashMap<>(); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); parser.setCompilerOptions(options); parser.setSource(source.toCharArray()); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java index 560d7d244..27a7d1e24 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java @@ -11,7 +11,6 @@ *******************************************************************/ package org.aspectj.tools.ajc; -import java.util.Iterator; import java.util.List; import org.aspectj.org.eclipse.jdt.core.dom.AST; diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java index 721cb3e22..bb205d430 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java @@ -12,7 +12,6 @@ package org.aspectj.tools.ajc; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.org.eclipse.jdt.core.SourceRange; diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java index 15fdf0d9f..138e6538c 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java @@ -17,6 +17,7 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.StringTokenizer; @@ -310,9 +311,7 @@ public class Ajc { } private void addMessagesTo(List<IMessage> aList, IMessage[] messages) { - for (IMessage message : messages) { - aList.add(message); - } + Collections.addAll(aList, messages); } private boolean isIncremental(String[] args) { diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index d5238b477..91fbc9b86 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -523,9 +523,7 @@ public abstract class AjcTestCase extends TestCase { */ protected List newMessageList(Message[] messages) { List ret = new ArrayList(); - for (Message message : messages) { - ret.add(message); - } + Collections.addAll(ret, messages); return ret; } @@ -789,7 +787,7 @@ public abstract class AjcTestCase extends TestCase { private List<String >tokenizeCommand(String command) { StringTokenizer st = new StringTokenizer(command," ", false); - ArrayList<String> arguments = new ArrayList<>(); + List<String> arguments = new ArrayList<>(); while(st.hasMoreElements()){ String nextToken =st.nextToken(); arguments.add(nextToken); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java index 9dff188ed..dc60334a7 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/DelegatingOutputStream.java @@ -12,7 +12,6 @@ package org.aspectj.tools.ajc; import java.io.IOException; import java.io.OutputStream; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/MainTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/MainTest.java index 7da3aa647..ddcd1046a 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/MainTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/MainTest.java @@ -13,6 +13,7 @@ package org.aspectj.tools.ajc; import java.util.ArrayList; +import java.util.List; import java.util.ResourceBundle; import org.aspectj.bridge.AbortException; @@ -23,7 +24,7 @@ import org.aspectj.bridge.AbortException; public class MainTest extends AjcTestCase { public void testMainbare() { - ArrayList<String> list = new ArrayList<>(); + List<String> list = new ArrayList<>(); // Usage now printed by Eclipse compiler so doesn't appear here in our message list // Main.bareMain(new String[] {"-help"}, false, list, null, null, null); // assertTrue(1 == list.size()); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java index 2d969c2f8..763f78f0b 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AbstractReferenceTypeDelegate.java @@ -13,6 +13,7 @@ package org.aspectj.weaver; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.aspectj.bridge.ISourceLocation; @@ -135,15 +136,11 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele AbstractReferenceTypeDelegate outerObjectType = (AbstractReferenceTypeDelegate) outerDelegate; if (outerObjectType.isNested()) { GenericSignature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass(); - for (GenericSignature.FormalTypeParameter parentParam : parentParams) { - typeParameters.add(parentParam); - } + Collections.addAll(typeParameters, parentParams); } GenericSignature.ClassSignature outerSig = outerObjectType.getGenericClassTypeSignature(); if (outerSig != null) { - for (FormalTypeParameter formalTypeParameter : outerSig.formalTypeParameters) { - typeParameters.add(formalTypeParameter); - } + Collections.addAll(typeParameters, outerSig.formalTypeParameters); } GenericSignature.FormalTypeParameter[] ret = new GenericSignature.FormalTypeParameter[typeParameters.size()]; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java index cd786e724..d759bc721 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Advice.java @@ -304,9 +304,7 @@ public abstract class Advice extends ShadowMunger { return allNames; } String[] result = new String[getBaseParameterCount()]; - for (int i = 0; i < result.length; i++) { - result[i] = allNames[i]; - } + if (result.length >= 0) System.arraycopy(allNames, 0, result, 0, result.length); return result; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java index c3f22b0b1..e71850c05 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java @@ -74,8 +74,8 @@ public class CrosscuttingMembers { this.shouldConcretizeIfNeeded = shouldConcretizeIfNeeded; } - private final Hashtable<String, Object> cflowFields = new Hashtable<>(); - private final Hashtable<String, Object> cflowBelowFields = new Hashtable<>(); + private final Map<String, Object> cflowFields = new Hashtable<>(); + private final Map<String, Object> cflowBelowFields = new Hashtable<>(); // public void addConcreteShadowMungers(Collection c) { // shadowMungers.addAll(c); @@ -293,8 +293,7 @@ public class CrosscuttingMembers { theseShadowMungers.add(munger); } } - Set<ShadowMunger> tempSet = new HashSet<>(); - tempSet.addAll(other.shadowMungers); + Set<ShadowMunger> tempSet = new HashSet<>(other.shadowMungers); Set<ShadowMunger> otherShadowMungers = new HashSet<>(); Set<ShadowMunger> otherInlinedAroundMungers = new HashSet<>(); for (ShadowMunger munger : tempSet) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java index 79f96e8fa..b80d2c3de 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembersSet.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java index 2e2f9e9df..b177d7ec6 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Dump.java @@ -17,7 +17,6 @@ import java.io.PrintStream; import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Properties; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java index 216186b26..2dbca28e3 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Lint.java @@ -19,7 +19,6 @@ import java.io.InputStream; import java.text.MessageFormat; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Properties; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java index 86caa48c5..d7bd742b8 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/MemberImpl.java @@ -211,7 +211,7 @@ public class MemberImpl implements Member { l.add(UnresolvedType.forSignature(sig.substring(start, i))); } } - UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[l.size()]); + UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[0]); UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length())); return new Object[] { returnType, paramTypes }; } else { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java index 3d88279af..9a322d98f 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/ResolvedType.java @@ -1082,7 +1082,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl l.add(m); } } - return l.toArray(new ResolvedMember[l.size()]); + return l.toArray(new ResolvedMember[0]); } public abstract ISourceContext getSourceContext(); @@ -1425,13 +1425,13 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl * ??? This method is O(N*M) where N = number of methods and M is number of inter-type declarations in my super */ public List<ConcreteTypeMunger> getInterTypeMungersIncludingSupers() { - ArrayList<ConcreteTypeMunger> ret = new ArrayList<>(); + List<ConcreteTypeMunger> ret = new ArrayList<>(); collectInterTypeMungers(ret); return ret; } public List<ConcreteTypeMunger> getInterTypeParentMungersIncludingSupers() { - ArrayList<ConcreteTypeMunger> ret = new ArrayList<>(); + List<ConcreteTypeMunger> ret = new ArrayList<>(); collectInterTypeParentMungers(ret); return ret; } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java index b48b87489..14690ad35 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java @@ -18,7 +18,6 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java index 2cc737347..f906a397e 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPatternList.java @@ -50,7 +50,7 @@ public class AnnotationPatternList extends PatternNode { } public AnnotationPatternList(List<AnnotationTypePattern> l) { - this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[l.size()])); + this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[0])); } protected AnnotationTypePattern[] getAnnotationPatterns() { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java index 7f7abd1e9..9365d4cb8 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java index ef537d807..15713e76d 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/BasicTokenSource.java @@ -160,7 +160,7 @@ public class BasicTokenSource implements ITokenSource { //System.out.println(tokens); - return new BasicTokenSource((IToken[])tokens.toArray(new IToken[tokens.size()]), context); + return new BasicTokenSource((IToken[])tokens.toArray(new IToken[0]), context); } private static String makeString(char ch) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java index 6903b9b83..4b108cf16 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java @@ -11,7 +11,6 @@ package org.aspectj.weaver.patterns; import java.io.IOException; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Set; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java index 8c2cb36b9..4e614824a 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/IfPointcut.java @@ -308,7 +308,7 @@ public class IfPointcut extends Pointcut { } } - ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[]) args.toArray(new Expr[args.size()]))); + ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[]) args.toArray(new Expr[0]))); // Remember... ifLastMatchedShadowId = shadow.shadowId; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java index 4e1ef74df..c0fed9aee 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PointcutRewriter.java @@ -252,9 +252,7 @@ public class PointcutRewriter { } // otherwise ... Pointcut[] subset = new Pointcut[ps.length - 1]; - for (int i = 1; i < ps.length; i++) { - subset[i - 1] = ps[i]; - } + if (ps.length - 1 >= 0) System.arraycopy(ps, 1, subset, 0, ps.length - 1); return new AndPointcut(ps[0], createAndsFor(subset)); } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java index e1a52f8c8..d5203bc86 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java index 2b17520a2..fdbc40d12 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java @@ -59,7 +59,7 @@ public class TypePatternList extends PatternNode { } public TypePatternList(List<TypePattern> l) { - this((TypePattern[]) l.toArray(new TypePattern[l.size()])); + this((TypePattern[]) l.toArray(new TypePattern[0])); } public int size() { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java index 162665c2c..b2d466565 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternQuestions.java @@ -14,7 +14,6 @@ package org.aspectj.weaver.patterns; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.aspectj.util.FuzzyBoolean; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java index dd95d4c77..11b385984 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java @@ -11,7 +11,6 @@ package org.aspectj.weaver.patterns; import java.io.IOException; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Set; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java index b8e58c342..b8c4ac31b 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java @@ -110,7 +110,7 @@ public class WildTypePattern extends TypePattern { } public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim) { - this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, false, TypePatternList.EMPTY); + this((NamePattern[]) names.toArray(new NamePattern[0]), includeSubtypes, dim, false, TypePatternList.EMPTY); } @@ -127,7 +127,7 @@ public class WildTypePattern extends TypePattern { public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams, TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound) { - this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, isVarArg, typeParams); + this((NamePattern[]) names.toArray(new NamePattern[0]), includeSubtypes, dim, isVarArg, typeParams); this.end = endPos; this.upperBound = upperBound; this.lowerBound = lowerBound; @@ -135,7 +135,7 @@ public class WildTypePattern extends TypePattern { } public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams) { - this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, isVarArg, typeParams); + this((NamePattern[]) names.toArray(new NamePattern[0]), includeSubtypes, dim, isVarArg, typeParams); this.end = endPos; } @@ -588,9 +588,7 @@ public class WildTypePattern extends TypePattern { @Override public TypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { NamePattern[] newNamePatterns = new NamePattern[namePatterns.length]; - for (int i = 0; i < namePatterns.length; i++) { - newNamePatterns[i] = namePatterns[i]; - } + System.arraycopy(namePatterns, 0, newNamePatterns, 0, namePatterns.length); if (newNamePatterns.length == 1) { String simpleName = newNamePatterns[0].maybeGetSimpleName(); if (simpleName != null) { @@ -1171,7 +1169,7 @@ public class WildTypePattern extends TypePattern { } } } - return ret.toArray(new String[ret.size()]); + return ret.toArray(new String[0]); } // public void postRead(ResolvedType enclosingType) { diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java index 5de4aa288..9edf23f8f 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateFactory.java @@ -18,7 +18,6 @@ import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedMemberImpl; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java index 28cd56607..e3e19e64b 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/reflect/ReflectionWorld.java @@ -10,13 +10,11 @@ package org.aspectj.weaver.reflect; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHandler; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.BCException; import org.aspectj.weaver.IWeavingSupport; import org.aspectj.weaver.ReferenceType; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java index 65de08759..38a18e1ad 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.tools; import java.io.File; import java.util.HashSet; -import java.util.Iterator; import java.util.Properties; import java.util.Set; diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java index 9454b209a..3fc92f5b4 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.aspectj.weaver.tools; -import org.aspectj.util.LangUtil; - public abstract class TraceFactory { public final static String DEBUG_PROPERTY = "org.aspectj.tracing.debug"; diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java index 9389fff8b..613437346 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/CommonWorldTests.java @@ -189,7 +189,7 @@ public abstract class CommonWorldTests extends TestCase { protected void mungersTest(ResolvedType ty, ShadowMunger[] x) { List<ShadowMunger> l = ty.getDeclaredShadowMungers(); - ShadowMunger[] array = (ShadowMunger[]) l.toArray(new ShadowMunger[l.size()]); + ShadowMunger[] array = (ShadowMunger[]) l.toArray(new ShadowMunger[0]); TestUtil.assertSetEquals(ty + " mungers:", x, array); } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java index 9f7daa756..69bc674ef 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/TestUtils.java @@ -298,7 +298,7 @@ public class TestUtils { l.add(str.substring(start, i).trim()); start = i + 1; } - return (String[]) l.toArray(new String[l.size()]); + return (String[]) l.toArray(new String[0]); } } diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java index 623af002f..13376d676 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ArgsTestCase.java @@ -14,7 +14,6 @@ import java.lang.reflect.Method; import junit.framework.TestCase; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.tools.JoinPointMatch; import org.aspectj.weaver.tools.PointcutExpression; import org.aspectj.weaver.tools.PointcutParameter; diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java index 9f524d836..f3609b7d7 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ParserTestCase.java @@ -700,8 +700,7 @@ public class ParserTestCase extends PatternsTestCase { WildAnnotationTypePattern watp = (WildAnnotationTypePattern) atp; Map<String,String> m = watp.annotationValues; Set<String> keys = m.keySet(); - List<String> orderedKeys = new ArrayList<>(); - orderedKeys.addAll(keys); + List<String> orderedKeys = new ArrayList<>(keys); Collections.sort(orderedKeys); StringBuffer sb = new StringBuffer(); for (Iterator<String> iterator = orderedKeys.iterator(); iterator.hasNext();) { diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java index f7d454f0c..9003b4b43 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/PointcutRewriterTest.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.util.Iterator; import java.util.Set; import java.util.StringTokenizer; diff --git a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java index b52146849..be9caeedf 100644 --- a/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java +++ b/org.aspectj.matcher/src/test/java/org/aspectj/weaver/patterns/ThisOrTargetTestCase.java @@ -19,7 +19,6 @@ import java.lang.reflect.Method; import junit.framework.TestCase; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.tools.JoinPointMatch; import org.aspectj.weaver.tools.PointcutExpression; import org.aspectj.weaver.tools.PointcutParameter; @@ -134,7 +134,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.13</version> <scope>test</scope> </dependency> </dependencies> diff --git a/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java b/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java index bc53f9317..db372494e 100644 --- a/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java +++ b/runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java @@ -13,7 +13,6 @@ * ******************************************************************/ package org.aspectj.runtime.internal.cflowstack; -import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.Enumeration; diff --git a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java index 2eb92e97b..244624d9b 100644 --- a/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java +++ b/runtime/src/test/java/org/aspectj/runtime/RuntimeTest.java @@ -15,9 +15,6 @@ package org.aspectj.runtime; import java.io.*; import org.aspectj.lang.*; -import org.aspectj.runtime.reflect.JoinPointImplTest; -import org.aspectj.runtime.reflect.RuntimePerformanceTest; -import org.aspectj.runtime.reflect.SignatureTest; import junit.framework.*; diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java index 354702f5a..fa9d24e93 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc10.java @@ -16,7 +16,6 @@ import java.io.File; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.StringTokenizer; diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java index 84f661cd5..68824ca80 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java @@ -14,13 +14,11 @@ package org.aspectj.tools.ant.taskdefs; import org.apache.tools.ant.*; import org.apache.tools.ant.types.*; -import org.apache.tools.ant.types.Path; import org.apache.tools.ant.taskdefs.*; import org.apache.tools.ant.util.JavaEnvUtils; import java.io.*; import java.util.List; -import java.util.Iterator; import java.util.ArrayList; import java.util.StringTokenizer; diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index 83dcd9911..141f2873b 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -22,7 +22,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; @@ -1159,7 +1158,6 @@ public class AjcTask extends MatchingTask { // package-private for testing String[] makeCommand() { - ArrayList result = new ArrayList(); if (0 < ignored.size()) { for (Object o : ignored) { logVerbose("ignored: " + o); @@ -1182,7 +1180,7 @@ public class AjcTask extends MatchingTask { outjarFixedup = true; } - result.addAll(cmd.extractArguments()); + ArrayList result = new ArrayList(cmd.extractArguments()); addListArgs(result); String[] command = (String[]) result.toArray(new String[0]); @@ -2038,7 +2036,7 @@ public class AjcTask extends MatchingTask { // } List extractArguments() { - ArrayList result = new ArrayList(); + List result = new ArrayList(); String[] cmds = command.getArguments(); if (!LangUtil.isEmpty(cmds)) { result.addAll(Arrays.asList(cmds)); diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java index 022dcae22..43125a862 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java @@ -53,8 +53,7 @@ public class Ajc extends DefaultCompilerAdapter { "-encoding", "-target" }); private static List<String> finalList(String[] args) { - List<String> result = new ArrayList<>(); - result.addAll(Arrays.asList(args)); + List<String> result = new ArrayList<>(Arrays.asList(args)); return Collections.unmodifiableList(result); } @@ -138,7 +137,7 @@ public class Ajc extends DefaultCompilerAdapter { argsList.add(args[i]); } } - return (String[])argsList.toArray(new String[argsList.size()]); + return (String[])argsList.toArray(new String[0]); } /** diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java index 80e9ed4a0..3a5f3b954 100644 --- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java +++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/Ajc11CompilerAdapterTest.java @@ -20,6 +20,7 @@ import org.aspectj.util.FileUtil; import java.io.File; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import junit.framework.TestCase; @@ -28,7 +29,7 @@ import junit.framework.TestCase; */ public class Ajc11CompilerAdapterTest extends TestCase { public static boolean LOGGING = false; - ArrayList tempFiles = new ArrayList(); + List tempFiles = new ArrayList(); public Ajc11CompilerAdapterTest(String name) { super(name); diff --git a/testing-client/src/main/java/org/aspectj/testing/Tester.java b/testing-client/src/main/java/org/aspectj/testing/Tester.java index d42bcd994..8e6e98db4 100644 --- a/testing-client/src/main/java/org/aspectj/testing/Tester.java +++ b/testing-client/src/main/java/org/aspectj/testing/Tester.java @@ -720,7 +720,7 @@ public class Tester { private static String[] diffIgnoreDups(Collection<String> set, String[] expected, String msg, boolean ignoreDups) { ArrayList<String> result = new ArrayList<>(); - ArrayList<String> actual = new ArrayList<>(set); + List<String> actual = new ArrayList<>(set); BitSet hits = new BitSet(); for (int i = 0; i < expected.length; i++) { if (!actual.remove(expected[i])) { diff --git a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java index 5533739a3..e757dfc4b 100644 --- a/testing-client/src/test/java/org/aspectj/testing/TesterTest.java +++ b/testing-client/src/test/java/org/aspectj/testing/TesterTest.java @@ -166,8 +166,8 @@ public class TesterTest extends TestCase { * @author isberg */ public static class MyTestReporter implements IMessageHandler { - public ArrayList<IMessage> failures = new ArrayList<>(); - public ArrayList<IMessage> passes = new ArrayList<>(); + public List<IMessage> failures = new ArrayList<>(); + public List<IMessage> passes = new ArrayList<>(); public void clear() { failures.clear(); diff --git a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java index 55295568a..4939368ab 100644 --- a/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java +++ b/testing-drivers/src/test/java/org/aspectj/testing/drivers/Harness.java @@ -28,7 +28,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -176,7 +175,7 @@ public class Harness { /** just don't say anything! */ protected boolean silentHarness; - private HashMap<String,Feature> features; + private Map<String,Feature> features; /** if true, do not delete temporary files. */ private boolean keepTemp; @@ -212,9 +211,8 @@ public class Harness { LangUtil.throwIaxIfFalse(!LangUtil.isEmpty(args), "empty args"); // read arguments final ArrayList<String> globals = new ArrayList<>(); - final ArrayList<String> files = new ArrayList<>(); - final LinkedList<String> argList = new LinkedList<>(); - argList.addAll(Arrays.asList(args)); + final List<String> files = new ArrayList<>(); + final LinkedList<String> argList = new LinkedList<>(Arrays.asList(args)); for (int i = 0; i < argList.size(); i++) { String arg = argList.get(i); List<String> aliases = aliasOptions(arg); @@ -605,7 +603,7 @@ public class Harness { /** print known aliases at the end of the syntax message */ protected void printAliases(PrintStream out) { LangUtil.throwIaxIfNull(out, "out"); - Properties props = getOptionAliases(); + Map props = getOptionAliases(); if (null == props) { return; } @@ -700,7 +698,7 @@ class FeatureHarness extends Harness { "-junit" + OPTION_DELIM + "-ajctestSkipKeywords=knownLimitation,purejava" }; static { - Properties optionAliases = Harness.getOptionAliases(); + Map optionAliases = Harness.getOptionAliases(); if (null != optionAliases) { for (int i = 1; i < ALIASES.length; i += 2) { optionAliases.put(ALIASES[i-1], ALIASES[i]); @@ -942,7 +940,7 @@ class TestMaker { } public Harness.RunResult run(AjcTest.Suite.Spec spec) { - ArrayList<IRunSpec> kids = spec.getChildren(); + Iterable<IRunSpec> kids = spec.getChildren(); for (IRunSpec iRunSpec : kids) { makeTest( (AjcTest.Spec) iRunSpec); } diff --git a/testing-drivers/src/test/java/org/aspectj/testing/drivers/TestingDriversModuleTests.java b/testing-drivers/src/test/java/org/aspectj/testing/drivers/TestingDriversModuleTests.java index d690a4b1f..d4b6f9900 100644 --- a/testing-drivers/src/test/java/org/aspectj/testing/drivers/TestingDriversModuleTests.java +++ b/testing-drivers/src/test/java/org/aspectj/testing/drivers/TestingDriversModuleTests.java @@ -13,7 +13,6 @@ package org.aspectj.testing.drivers; import junit.framework.*; -import junit.framework.Test; public class TestingDriversModuleTests extends TestCase { diff --git a/testing-util/pom.xml b/testing-util/pom.xml index 5f1c885bd..8e5262fd6 100644 --- a/testing-util/pom.xml +++ b/testing-util/pom.xml @@ -34,7 +34,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.13</version> </dependency> <dependency> <groupId>jdiff</groupId> diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index 76b7a181a..cf2ae8ef0 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -28,18 +28,8 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.net.URLClassLoader; +import java.util.*; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.MessageUtil; @@ -56,7 +46,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; -import junit.runner.TestCaseClassLoader; +import sun.net.www.ParseUtil; /** * Things that junit should perhaps have, but doesn't. Note the file-comparison methods require JDiff to run, but JDiff types are @@ -383,7 +373,7 @@ public final class TestUtil { public static Object runMethod(String classPath, String className, String methodName, Object[] args) { classPath += File.pathSeparator + System.getProperty("java.class.path"); - ClassLoader loader = new TestCaseClassLoader(classPath); + ClassLoader loader = new URLClassLoader(pathToURLs(classPath), null); Class c = null; try { @@ -395,6 +385,33 @@ public final class TestUtil { } /** + * @see sun.misc.URLClassPath#pathToURLs(String) + */ + public static URL[] pathToURLs(String path) { + StringTokenizer st = new StringTokenizer(path, File.pathSeparator); + URL[] urls = new URL[st.countTokens()]; + int count = 0; + while (st.hasMoreTokens()) { + File f = new File(st.nextToken()); + try { + f = new File(f.getCanonicalPath()); + } catch (IOException x) { + // use the non-canonicalized filename + } + try { + urls[count++] = ParseUtil.fileToEncodedURL(f); + } catch (IOException x) { } + } + + if (urls.length != count) { + URL[] tmp = new URL[count]; + System.arraycopy(urls, 0, tmp, 0, count); + urls = tmp; + } + return urls; + } + + /** * Checks that two multi-line strings have the same value. Each line is trimmed before comparision Produces an error on the * particular line of conflict */ diff --git a/testing/pom.xml b/testing/pom.xml index d7e167d8b..d0c20be24 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -134,7 +134,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.13</version> </dependency> <dependency> <groupId>commons</groupId> diff --git a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java index 546eadba3..98878dcbc 100644 --- a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java +++ b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java @@ -36,13 +36,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.text.DateFormat; //import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; +import java.util.*; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -1426,9 +1420,7 @@ public class Ajctest extends Task implements PropertyChangeListener { public AjdocWrapper(Testset testset, List args) { super(testset, ajdocArgs(args), true); String[] cmds = testset.getAjdoc().getCommandline().getCommandline(); - for (String cmd : cmds) { - this.args.add(cmd); - } + Collections.addAll(this.args, cmds); } String getMainClassName() { return "org.aspectj.tools.ajdoc.Main"; diff --git a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java index 2b7e4942f..ca9a7f431 100644 --- a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java @@ -13,7 +13,6 @@ package org.aspectj.testing; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.apache.commons.digester.Digester; @@ -48,7 +47,7 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { return testMap; } - public static Test loadSuite(Class<?> testCaseClass) { + public static Test loadSuite(Class<? extends TestCase> testCaseClass) { TestSuite suite = new TestSuite(testCaseClass.getName()); //suite.addTestSuite(testCaseClass); diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index ca7d0f232..8e1fd2612 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -87,10 +87,8 @@ public class OutputSpec { createFailureMessage(output, -1, outputFound.size()); return; } - List<String> expected = new ArrayList<>(); - expected.addAll(expectedOutputLines); - List<String> found = new ArrayList<>(); - found.addAll(outputFound); + List<String> expected = new ArrayList<>(expectedOutputLines); + List<String> found = new ArrayList<>(outputFound); for (String lineFound : outputFound) { for (String lineExpected : expectedOutputLines) { if (lineFound.contains(lineExpected)) { diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java index e5e2fcdb9..68e14ec2e 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Stack; +import junit.framework.TestCase; import org.apache.commons.digester.Digester; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -81,7 +82,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { * @param testCaseClass * @return */ - public static Test loadSuite(Class<?> testCaseClass) { + public static Test loadSuite(Class<? extends TestCase> testCaseClass) { TestSuite suite = new TestSuite(testCaseClass.getName()); suite.addTestSuite(testCaseClass); TestSetup wrapper = new TestSetup(suite) { @@ -415,10 +416,8 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { public List<LocalVariable> sortedLocalVariables(LocalVariableTable lvt) { List<LocalVariable> l = new ArrayList<>(); LocalVariable lv[] = lvt.getLocalVariableTable(); - for (LocalVariable lvEntry : lv) { - l.add(lvEntry); - } - Collections.sort(l, new MyComparator()); + Collections.addAll(l, lv); + l.sort(new MyComparator()); return l; } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java index cf615f6d1..ed4f560c0 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java @@ -83,7 +83,7 @@ abstract public class AbstractRunSpec implements IRunSpec { private boolean skipAll; protected String xmlElementName; // nonfinal only for clone() - protected final ArrayList<String> keywords; + protected final List<String> keywords; protected final IMessageHolder /* IMessage */messages; protected final ArrayList<String> options; protected final ArrayList<String> paths; @@ -197,7 +197,7 @@ abstract public class AbstractRunSpec implements IRunSpec { } } - public ArrayList<String> getKeywordsList() { + public List<String> getKeywordsList() { return makeList(keywords); } @@ -257,7 +257,7 @@ abstract public class AbstractRunSpec implements IRunSpec { // --------------- (String) paths /** @return ArrayList of String paths */ - public ArrayList<String> getPathsList() { + public List<String> getPathsList() { return makeList(paths); } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java index 6a7932703..da265e7f9 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java index 52a3e2266..2ff173362 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java @@ -250,7 +250,7 @@ public class AjcSpecTest extends TestCase { sameDirChangesList(lhs.dirChanges, rhs.dirChanges, a); } - public static void sameDirChangesList(ArrayList<DirChanges.Spec> lhs, ArrayList<DirChanges.Spec> rhs, Assert a) { + public static void sameDirChangesList(List<DirChanges.Spec> lhs, List<DirChanges.Spec> rhs, Assert a) { if ((null == lhs) && (null == rhs)) { return; } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java index 7bbc50adf..5ca41509f 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java @@ -161,7 +161,7 @@ public class AjcTest extends RunSpecIterator { * @return the unmodifiable List of titles (maybe empty, never null) */ private static List<String> parseTitlesList(String titlesList) { - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); String last = null; StringTokenizer st = new StringTokenizer(titlesList, ","); while (st.hasMoreTokens()) { @@ -206,7 +206,7 @@ public class AjcTest extends RunSpecIterator { * @return the unmodifiable List of titles (maybe empty, never null) */ private static List<String> readTitlesFile(File titlesFile, boolean fail) { - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); Reader reader = null; try { reader = new FileReader(titlesFile); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java index 7a5bff3df..d85384a8a 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java @@ -22,7 +22,6 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -729,7 +728,7 @@ public class CompilerRun implements IAjcRun { private static String updateBootclasspathForSourceVersion( String sourceVersion, String compilerName, - ArrayList toAdd) { + List toAdd) { if (null == sourceVersion) { return null; } @@ -1497,7 +1496,7 @@ public class CompilerRun implements IAjcRun { String seek; /** if setup completed, this has the combined global/local options */ - ArrayList commandOptions; + List commandOptions; public Object clone() { TestSetup testSetup = new TestSetup(); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java index abac95dfe..7e73a9233 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java @@ -15,7 +15,6 @@ package org.aspectj.testing.harness.bridge; import java.util.Arrays; -import java.util.Iterator; import java.util.Set; import org.aspectj.bridge.MessageHandler; diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java index e3e60e028..5a3ad13ab 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java @@ -15,7 +15,6 @@ package org.aspectj.testing.harness.bridge; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessageHandler; @@ -469,19 +468,19 @@ public class DirChanges { boolean fastFail; /** relative paths (String) of expected files added */ - final ArrayList<String> added; + final List<String> added; /** relative paths (String) of expected files removed/deleted */ - final ArrayList<String> removed; + final List<String> removed; /** relative paths (String) of expected files updated/changed */ - final ArrayList<String> updated; + final List<String> updated; /** relative paths (String) of expected files NOT * added, removed, or changed * XXX unchanged unimplemented */ - final ArrayList<String> unchanged; + final List<String> unchanged; public Spec() { added = new ArrayList<>(); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index 28db821cb..696d491a5 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -150,7 +150,7 @@ public class FlatSuiteReader implements SFileReader.Maker { throw new AbortException("expected sources at " + reader); } - ArrayList<Message> exp = new ArrayList<>(); + List<Message> exp = new ArrayList<>(); // !compile || noerrors || className {runOption..} String first = words[0]; if ("!compile".equals(first)) { @@ -290,7 +290,7 @@ public class FlatSuiteReader implements SFileReader.Maker { result.description = input; ArrayList<String> newOptions = new ArrayList<>(); - ArrayList<String> optionsCopy = result.getOptionsList(); + Iterable<String> optionsCopy = result.getOptionsList(); for (String option: optionsCopy) { if (option.startsWith("-")) { newOptions.add("!" + option.substring(1)); @@ -325,7 +325,7 @@ public class FlatSuiteReader implements SFileReader.Maker { */ private List<Message> makeMessages(// XXX weak - also support expected exceptions, etc. Kind kind, String[] words, int start, File lastFile) { - ArrayList<Message> result = new ArrayList<>(); + List<Message> result = new ArrayList<>(); for (int i = start; i < words.length; i++) { ISourceLocation sl = BridgeUtil.makeSourceLocation(words[i], lastFile); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java index ad62c9735..22e52ec61 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java @@ -71,7 +71,7 @@ public class Globals { && FileUtil.canReadFile(F_aspectjrt_jar) && FileUtil.canReadFile(J2SE13_RTJAR) && FileUtil.canReadFile(J2SE14_RTJAR)); - HashMap map = new HashMap(); + Map map = new HashMap(); map.put("1.2", "java.lang.ref.Reference"); map.put("1.3", "java.lang.reflect.Proxy"); map.put("1.4", "java.nio.Buffer"); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java index a0c48878e..e3bbb9209 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java @@ -409,7 +409,7 @@ public class IncCompilerRun implements IAjcRun { addItems(classesRemoved, items); } - private void addItems(ArrayList list, String items) { + private void addItems(List list, String items) { if (null != items) { String[] classes = XMLWriter.unflattenList(items); if (!LangUtil.isEmpty(classes)) { diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java index ea88c49f1..acc3245ca 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java @@ -167,8 +167,7 @@ public class JavaRun implements IAjcRun { File[] files = sandbox.findFiles(spec.aspectpath); aspectURLs = FileUtil.getFileURLs(files); } - ArrayList classpath = new ArrayList(); - classpath.addAll(Arrays.asList(aspectURLs)); + ArrayList classpath = new ArrayList(Arrays.asList(aspectURLs)); final URL[] classURLs; { classpath.addAll(Arrays.asList(clAndLibs)); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java index 7aaa1767c..b557da6a6 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java @@ -15,7 +15,6 @@ package org.aspectj.testing.harness.bridge; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.xml.parsers.DocumentBuilder; diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java index a0b4f5e96..1bda6adda 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java @@ -13,12 +13,7 @@ package org.aspectj.testing.harness.bridge; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.ListIterator; -import java.util.Stack; +import java.util.*; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; @@ -51,10 +46,10 @@ public class Validator { private final Stack<IMessageHandler> handlers; /** list of File registered for deletion on demand */ - private final ArrayList<File> tempFiles; // deleteTempFiles requires ListIterator.remove() + private final List<File> tempFiles; // deleteTempFiles requires ListIterator.remove() /** list of Sandboxes registered for cleanup on demand */ - private final ArrayList<Sandbox> sandboxes; + private final List<Sandbox> sandboxes; /** if true, throw AbortException on failure */ boolean abortOnFailure; diff --git a/testing/src/test/java/org/aspectj/testing/run/RunListeners.java b/testing/src/test/java/org/aspectj/testing/run/RunListeners.java index 4eb8e7a74..ebdc227d0 100644 --- a/testing/src/test/java/org/aspectj/testing/run/RunListeners.java +++ b/testing/src/test/java/org/aspectj/testing/run/RunListeners.java @@ -16,6 +16,7 @@ package org.aspectj.testing.run; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; /** * Aggregate listeners into one and run synchronously in order added. @@ -23,7 +24,7 @@ import java.util.Iterator; */ public class RunListeners extends RunListener implements IRunListener { - ArrayList listeners; + List listeners; public RunListeners() { listeners = new ArrayList(); } diff --git a/testing/src/test/java/org/aspectj/testing/run/RunStatus.java b/testing/src/test/java/org/aspectj/testing/run/RunStatus.java index 272f57103..c82a61ed1 100644 --- a/testing/src/test/java/org/aspectj/testing/run/RunStatus.java +++ b/testing/src/test/java/org/aspectj/testing/run/RunStatus.java @@ -15,7 +15,6 @@ package org.aspectj.testing.run; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; diff --git a/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java b/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java index 3871ee74b..b20a5650a 100644 --- a/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java +++ b/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java @@ -14,6 +14,7 @@ package org.aspectj.testing.taskdefs; import java.io.File; import java.util.ArrayList; +import java.util.List; import org.aspectj.bridge.IMessageHolder; import org.aspectj.bridge.MessageHandler; @@ -33,7 +34,7 @@ import junit.framework.TestCase; public class AjcTaskCompileCommandTest extends TestCase { static boolean loggedWarning = false; static boolean runAllTests = true; - static ArrayList<File> tempFiles = new ArrayList<>(); + static List<File> tempFiles = new ArrayList<>(); private static File getClassesDir() { File tempDir = FileUtil.getTempDir("AjcTaskCompileCommandTest-classes"); @@ -41,7 +42,7 @@ public class AjcTaskCompileCommandTest extends TestCase { return tempDir; } - private static void addCommonArgs(ArrayList<String> list) { + private static void addCommonArgs(List<String> list) { list.add("-d"); list.add(getClassesDir().getAbsolutePath()); list.add("-classpath"); diff --git a/testing/src/test/java/org/aspectj/testing/util/Diffs.java b/testing/src/test/java/org/aspectj/testing/util/Diffs.java index c9a58e99f..43739b752 100644 --- a/testing/src/test/java/org/aspectj/testing/util/Diffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/Diffs.java @@ -148,8 +148,8 @@ public class Diffs { IMessage[] actual, IMessage.Kind[] ignoreExpectedKinds, IMessage.Kind[] ignoreActualKinds) { - ArrayList exp = getExcept(expected, ignoreExpectedKinds); - ArrayList act = getExcept(actual, ignoreActualKinds); + List exp = getExcept(expected, ignoreExpectedKinds); + List act = getExcept(actual, ignoreActualKinds); ArrayList missing = new ArrayList(); List unexpected = new ArrayList(); @@ -161,8 +161,8 @@ public class Diffs { } else { ListIterator expectedIterator = exp.listIterator(); int lastLine = Integer.MIN_VALUE + 1; - ArrayList expectedFound = new ArrayList(); - ArrayList expectedForLine = new ArrayList(); + List expectedFound = new ArrayList(); + List expectedForLine = new ArrayList(); for (ListIterator iter = act.listIterator(); iter.hasNext();) { IMessage actualMessage = (IMessage) iter.next(); int actualLine = getLine(actualMessage); @@ -452,7 +452,7 @@ public class Diffs { if (LangUtil.isEmpty(skip)) { sink.addAll(Arrays.asList(source)); - Collections.sort(sink, MESSAGE_LINEKIND); + sink.sort(MESSAGE_LINEKIND); return sink; } for (IMessage message : source) { @@ -467,7 +467,7 @@ public class Diffs { sink.add(message); } } - Collections.sort(sink, MESSAGE_LINEKIND); + sink.sort(MESSAGE_LINEKIND); return sink; } diff --git a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java index ab780cd29..4f9f56424 100644 --- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java @@ -25,12 +25,7 @@ import java.io.StringBufferInputStream; import java.io.StringWriter; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.Vector; +import java.util.*; import java.util.jar.Attributes; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; @@ -131,7 +126,7 @@ public class FileUtil { final boolean checkExpected = !LangUtil.isEmpty(expectedPaths); // normalize sources to ignore - final ArrayList expected = (!checkExpected ? null : new ArrayList()); + final List expected = (!checkExpected ? null : new ArrayList()); if (checkExpected) { for (String srcPath : expectedPaths) { if (!LangUtil.isEmpty(srcPath)) { @@ -185,9 +180,8 @@ public class FileUtil { // skip if not file or not right time return false; } - }; - ArrayList unexp = new ArrayList(); - unexp.addAll(Arrays.asList(dir.listFiles(touchedCollector))); + }; + List unexp = new ArrayList(Arrays.asList(dir.listFiles(touchedCollector))); // report any unexpected changes return Diffs.makeDiffs(label, expected, unexp, String.CASE_INSENSITIVE_ORDER); diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java index ddf3a832a..b4acc5ce3 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java @@ -402,8 +402,7 @@ public class LangUtil { * @see Util#combine(Object[], Object[]) */ public static String[] combine(String[] one, String[] two) { - ArrayList twoList = new ArrayList(); - twoList.addAll(org.aspectj.util.LangUtil.arrayAsList(two)); + List twoList = new ArrayList(org.aspectj.util.LangUtil.arrayAsList(two)); ArrayList result = new ArrayList(); if (null != one) { for (String s : one) { @@ -938,14 +937,12 @@ public class LangUtil { if ((0 == actualListIn.size()) && (0 == expectedListIn.size()) ) { return; } - - ArrayList expected = new ArrayList(); - expected.addAll(expectedListIn); - Collections.sort(expected, comparator); - - ArrayList actual = new ArrayList(); - actual.addAll(actualListIn); - Collections.sort(actual, comparator); + + List expected = new ArrayList(expectedListIn); + expected.sort(comparator); + + List actual = new ArrayList(actualListIn); + actual.sort(comparator); Iterator actualIter = actual.iterator(); Object act = null; diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java index 30f2a0b06..853e51f50 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java @@ -67,7 +67,7 @@ public class LangUtilTest extends TestCase { void checkUnflatten(FTest test) { String[] exp = test.unflattened; - ArrayList result = LangUtil.unflatten(test.toUnflatten, test.spec); + List result = LangUtil.unflatten(test.toUnflatten, test.spec); String label = test + " -> " + result; assertNotNull(label, result); @@ -96,7 +96,7 @@ public class LangUtilTest extends TestCase { public void testArrayList() { - ArrayList l = new ArrayList(); + List l = new ArrayList(); l.add(null); l.add(null); assertTrue(null == l.get(0)); @@ -269,16 +269,15 @@ public class LangUtilTest extends TestCase { if (unmodifiable) { return Collections.unmodifiableList(Arrays.asList(ra)); } else { - ArrayList list = new ArrayList(); - list.addAll(Arrays.asList(ra)); + List list = new ArrayList(Arrays.asList(ra)); return list; } } /** check both hard and soft - assuming list contain String */ void checkDiff(List expected, List actual, List missing, List extra) { - ArrayList extraOut = new ArrayList(); - ArrayList missingOut = new ArrayList(); + List extraOut = new ArrayList(); + List missingOut = new ArrayList(); LangUtil.makeDiffs(expected, actual, missingOut, extraOut); checkSame(missing, missingOut); checkSame(extra, extraOut); @@ -302,8 +301,8 @@ public class LangUtilTest extends TestCase { /** check only soft - assuming list contain String */ void checkDiffSoft(List expected, List actual, List missing, List extra) { - ArrayList extraOut = new ArrayList(); - ArrayList missingOut = new ArrayList(); + List extraOut = new ArrayList(); + List missingOut = new ArrayList(); LangUtil.makeSoftDiffs(expected, actual, missingOut, extraOut, String.CASE_INSENSITIVE_ORDER); checkSameSoft(missing, missingOut); @@ -317,9 +316,8 @@ public class LangUtilTest extends TestCase { String label = one + "?=" + two; assertTrue(label, (null == one) == (null == two)); if (null != one) { - ArrayList aone = new ArrayList(); - aone.addAll(one); - ArrayList atwo = new ArrayList(); + List aone = new ArrayList(one); + List atwo = new ArrayList(); aone.addAll(two); Collections.sort(aone); Collections.sort(atwo); diff --git a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java index a576c4ae4..973f57b97 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java +++ b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java @@ -24,7 +24,6 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import javax.swing.text.MutableAttributeSet; @@ -171,10 +170,10 @@ public class LinkCheck { private final Messages messages; private final HTMLEditorKit.Parser parser; // XXX untested - stateful - private final ArrayList<Link> linksToCheck; - private final ArrayList<String> checkedUrls; // String (URL.toString) - private final ArrayList<String> validRefs; // String (URL.toString) - private final ArrayList<String> refsToCheck; // String (URL.toString) + private final List<Link> linksToCheck; + private final List<String> checkedUrls; // String (URL.toString) + private final List<String> validRefs; // String (URL.toString) + private final List<String> refsToCheck; // String (URL.toString) private final Link.Check checkExists; private final Link.Check checkContents; @@ -221,7 +220,7 @@ public class LinkCheck { } public synchronized void run() { - ArrayList<Link> list = new ArrayList<>(); + List<Link> list = new ArrayList<>(); while (0 < linksToCheck.size()) { messages.checkingLinks(linksToCheck.size()); list.clear(); diff --git a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java index 954ab38c0..178cb88bb 100644 --- a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; @@ -71,9 +70,8 @@ public class MessageUtilTest extends TestCase { List getSampleMessageTexts() { if (null == messageTexts) { - ArrayList result = new ArrayList(); - result.addAll(Arrays.asList(new String[] - { "one", "two", "now is the time for all good men..." })); + List result = new ArrayList(Arrays.asList(new String[] + {"one", "two", "now is the time for all good men..."})); messageTexts = result; } return messageTexts; @@ -81,7 +79,7 @@ public class MessageUtilTest extends TestCase { List getSampleExceptions() { if (null == exceptions) { - ArrayList result = new ArrayList(); + List result = new ArrayList(); int i = 1; result.add(new Error("Error " + i++)); result.add(new RuntimeException("RuntimeException " + i++)); @@ -93,7 +91,7 @@ public class MessageUtilTest extends TestCase { List getSampleLocations() { if (null == locations) { - ArrayList result = new ArrayList(); + List result = new ArrayList(); File file = new File("testsrc/org/aspectj/testing/util/MessageUtilTest.java"); result.add(new SourceLocation(file, 1, 2, 1)); result.add(new SourceLocation(file, 100, 100, 0)); diff --git a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java index f49ba3b87..8bde398ed 100644 --- a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; diff --git a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java index 11b9ea2b4..0b9d7ef41 100644 --- a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java @@ -34,10 +34,6 @@ public class StructureModelUtilTest extends AjdeCoreTestCase { "figures" + File.separator + "primitives" + File.separator + "planar" + File.separator + "Point.java", "figures" + File.separator + "primitives" + File.separator + "solid" + File.separator + "SolidPoint.java" }; - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureModelUtilTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(StructureModelUtilTest.class); diff --git a/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java b/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java index 8a753dfc7..cac9816cd 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java @@ -23,7 +23,6 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; /** @@ -41,7 +40,7 @@ public class TestClassLoader extends URLClassLoader { super(urls); this.urlsForDebugString = urls; LangUtil.throwIaxIfComponentsBad(dirs, "dirs", null); - ArrayList dcopy = new ArrayList(); + List dcopy = new ArrayList(); if (!LangUtil.isEmpty(dirs)) { dcopy.addAll(Arrays.asList(dirs)); diff --git a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java index dbb0c1bb1..ca1aa72ed 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java @@ -21,7 +21,6 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -83,8 +82,8 @@ public class TestDiffs { // XXX pretty dumb implementation Diffs tests = Diffs.makeDiffs("tests", exp, act, TestResult.BY_NAME); // remove missing/unexpected (removed, added) tests from results // otherwise, unexpected-[pass|fail] look like [fixes|broken] - ArrayList expResults = trimByName(exp, tests.missing); - ArrayList actResults = trimByName(act, tests.unexpected); + List expResults = trimByName(exp, tests.missing); + List actResults = trimByName(act, tests.unexpected); Diffs results = Diffs.makeDiffs("results", expResults, actResults, TestResult.BY_PASSNAME); @@ -141,8 +140,7 @@ public class TestDiffs { // XXX pretty dumb implementation * @return ArrayList with all input except those in trim (by name) */ private static ArrayList trimByName(List input, List trim) { - ArrayList result = new ArrayList(); - result.addAll(input); + ArrayList result = new ArrayList(input); if (!LangUtil.isEmpty(input) && !LangUtil.isEmpty(trim)) { for (ListIterator iter = result.listIterator(); iter.hasNext();) { TestResult inputItem = (TestResult) iter.next(); @@ -160,7 +158,7 @@ public class TestDiffs { // XXX pretty dumb implementation /** split input List by whether the TestResult element passed or failed */ - private static void split(List input, ArrayList pass, ArrayList fail) { + private static void split(List input, List pass, List fail) { for (Object o : input) { TestResult result = (TestResult) o; if (result.pass) { @@ -281,8 +279,7 @@ public class TestDiffs { // XXX pretty dumb implementation actualFailed = safeList(failed); // stillPassing: expected.passed w/o broken, missingPasses - passed = new ArrayList(); - passed.addAll(expectedPassed); + passed = new ArrayList(expectedPassed); passed = trimByName(passed, this.broken); ArrayList missingPasses = new ArrayList(); ArrayList missingFails = new ArrayList(); @@ -291,8 +288,7 @@ public class TestDiffs { // XXX pretty dumb implementation stillPassing = safeList(passed); // stillFailing: expected.failed w/o fixed, missingFails - failed = new ArrayList(); - failed.addAll(expectedFailed); + failed = new ArrayList(expectedFailed); failed = trimByName(failed, this.fixed); failed = trimByName(failed, missingFails); stillFailing = safeList(failed); diff --git a/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java b/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java index 17fa8234d..a0c5e115f 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java @@ -18,6 +18,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.List; import java.util.ListIterator; import org.aspectj.util.FileUtil; @@ -67,7 +68,7 @@ public class TestDiffsTest extends TestCase { } } - ArrayList tempFiles; + List tempFiles; /** * Constructor for FileUtilTest. * @param arg0 diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Option.java b/testing/src/test/java/org/aspectj/testing/util/options/Option.java index b9c6d2cab..5d3ec4ba6 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/Option.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/Option.java @@ -365,7 +365,7 @@ public class Option implements Comparable { private final Map familyNameToFamily = new TreeMap(); /** enforce uniqueness of options */ - private final ArrayList names = new ArrayList(); + private final List names = new ArrayList(); public Factory(String factoryName) { this.factoryName = factoryName; diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Options.java b/testing/src/test/java/org/aspectj/testing/util/options/Options.java index 92e84c106..03b3a6d51 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/Options.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/Options.java @@ -14,6 +14,7 @@ package org.aspectj.testing.util.options; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.aspectj.util.LangUtil; @@ -59,7 +60,7 @@ public class Options { return sb.toString(); } - private final ArrayList options = new ArrayList(); + private final List options = new ArrayList(); private final boolean stopAtFirstMatch; private boolean frozen = !FROZEN; diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Values.java b/testing/src/test/java/org/aspectj/testing/util/options/Values.java index 7a04fbed0..de35c8c67 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/Values.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/Values.java @@ -398,13 +398,11 @@ public class Values { String s = value.prefix.render(output[0]); if (null != s) { // this means the prefix is set list.add(s); - for (int j = 1; j < output.length; j++) { - list.add(output[j]); - } + list.addAll(Arrays.asList(output).subList(1, output.length)); } } } - return (String[]) list.toArray(new String[list.size()]); + return (String[]) list.toArray(new String[0]); } private final Option.Value[] values; @@ -700,9 +698,7 @@ public class Values { private void add(int i) { if (insert >= input.length) { int[] temp = new int[insert + 256]; - for (int j = 0; j < input.length; j++) { - temp[j] = input[j]; - } + System.arraycopy(input, 0, temp, 0, input.length); input = temp; } input[insert++] = i; @@ -710,9 +706,7 @@ public class Values { private int[] getList() { int[] result = new int[insert]; - for (int i = 0; i < result.length; i++) { - result[i] = input[i]; - } + if (result.length >= 0) System.arraycopy(input, 0, result, 0, result.length); return result; } } diff --git a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java index d6ebc774e..b60e56470 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java +++ b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.aspectj.testing.harness.bridge.AjcSpecTest; import org.aspectj.testing.harness.bridge.AjcTest; @@ -35,7 +36,7 @@ import junit.framework.TestCase; */ public class AjcSpecXmlReaderTest extends TestCase { - ArrayList<File> tempFiles = new ArrayList<>(); + List<File> tempFiles = new ArrayList<>(); /** * Constructor for AjcSpecXmlReaderTest. * @param name @@ -111,7 +112,7 @@ public class AjcSpecXmlReaderTest extends TestCase { String xml2Path = path + ".tmp.xml"; final File file1 = new File(xmlPath); - final ArrayList<File> toDelete = new ArrayList<>(); + final List<File> toDelete = new ArrayList<>(); final AjcSpecXmlReader writer = AjcSpecXmlReader.getReader(); assertTrue("" + file1, file1.canRead()); @@ -154,7 +155,7 @@ public class AjcSpecXmlReaderTest extends TestCase { AjcSpecXmlReader writer = AjcSpecXmlReader.getReader(); File file0 = new File(txtPath); File file1 = new File(xmlPath); - ArrayList<File> toDelete = new ArrayList<>(); + List<File> toDelete = new ArrayList<>(); AjcTest.Suite.Spec suite0 = null; if (file0.canRead()) { System.out.println("reading " + file0); diff --git a/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java b/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java index 342484a76..3201d4288 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java +++ b/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java @@ -16,6 +16,7 @@ package org.aspectj.testing.xml; import java.io.File; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.aspectj.bridge.IMessage; import org.aspectj.util.LangUtil; @@ -27,7 +28,7 @@ import junit.framework.TestCase; */ public class MessageListXmlReaderTest extends TestCase { - ArrayList tempFiles = new ArrayList(); + List tempFiles = new ArrayList(); public MessageListXmlReaderTest(String name) { super(name); } diff --git a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java index 969c8ecd8..970a1c457 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java +++ b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java @@ -16,7 +16,6 @@ package org.aspectj.testing.xml; import java.io.File; import java.util.ArrayList; //import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; @@ -41,7 +40,7 @@ public class SoftMessage implements IMessage { private String details; private int id; private int sourceStart,sourceEnd; - private final ArrayList extraSourceLocations = new ArrayList(); + private final List extraSourceLocations = new ArrayList(); //private ISourceLocation pseudoSourceLocation; // set directly // collapse enclosed source location for shorter, property-based xml diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests.java b/tests/src/test/java/org/aspectj/systemtest/AllTests.java index 206738dd4..f4cfe4d2c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/AllTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests.java @@ -4,8 +4,8 @@ * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * + * http://www.eclipse.org/legal/epl-v10.html + * * ******************************************************************/ package org.aspectj.systemtest; @@ -37,6 +37,8 @@ import junit.framework.TestSuite; */ public class AllTests { + public final static boolean VERBOSE = System.getProperty("aspectj.tests.verbose", "true").equals("true"); + public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.3"); //$JUnit-BEGIN$ diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java index 4558a4c39..a8200876c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java @@ -1,10 +1,10 @@ /******************************************************************************* * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Andy Clement - initial implementation *******************************************************************************/ @@ -14,22 +14,31 @@ import org.aspectj.testing.XMLBasedAjcTestCase; import junit.framework.Test; - public class SerialVersionUIDTests extends XMLBasedAjcTestCase { - public void testTheBasics() { runTest("basic"); } - public void testTheBasicsWithLint() { runTest("basic - lint"); } - public void testHorrible() { runTest("horrible"); } - - public void testAbstractClass() { runTest("abstract class");} - - // - public static Test suite() { - return XMLBasedAjcTestCase.loadSuite(SerialVersionUIDTests.class); - } - - protected java.net.URL getSpecFile() { - return getClassResource("serialversionuid.xml"); - } - + public void testTheBasics() { + runTest("basic"); + } + + public void testTheBasicsWithLint() { + runTest("basic - lint"); + } + + public void testHorrible() { + runTest("horrible"); + } + + public void testAbstractClass() { + runTest("abstract class"); + } + + // + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SerialVersionUIDTests.class); + } + + protected java.net.URL getSpecFile() { + return getClassResource("serialversionuid.xml"); + } + } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java index 6fa9818ae..2f473957e 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java @@ -535,8 +535,6 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase { IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); IProgramElement pe = top.findElementForLabel(top.getRoot(), kind, ipeName); String found = pe.getHandleIdentifier(); - System.err.println("expected: " + expectedHandle); - System.err.println("actual: " + found); assertEquals("handleIdentifier - expected " + expectedHandle + ", but found " + found, expectedHandle, found); } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java index dd340c770..0a6538ef9 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java @@ -1,11 +1,11 @@ /******************************************************************** - * Copyright (c) 2006 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: + * Copyright (c) 2006 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: * Adrian Colyer initial implementation * Helen Hawkins Converted to new interface (bug 148190) *******************************************************************/ @@ -34,8 +34,6 @@ import org.aspectj.testing.util.FileUtil; public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeInteractionTestbed { - public static boolean VERBOSE = false; - public static void dumptree(IProgramElement node, int indent) { for (int i = 0; i < indent; i++) { System.out.print(" "); @@ -72,7 +70,6 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI protected void setUp() throws Exception { super.setUp(); - AjdeInteractionTestbed.VERBOSE = VERBOSE; AjState.FORCE_INCREMENTAL_DURING_TESTING = true; } @@ -100,12 +97,13 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI File projDir = new File(getWorkingDir(), p); return new File(projDir, "bin" + File.separator + filename); } - + public void build(String projectName) { constructUpToDateLstFile(projectName, "build.lst"); doBuild(projectName); - if (AjdeInteractionTestbed.VERBOSE) + if (AjdeInteractionTestbed.VERBOSE) { printBuildReport(projectName); + } } public int getRelationshipCount(String project) { @@ -124,8 +122,9 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI public void fullBuild(String projectName) { constructUpToDateLstFile(projectName, "build.lst"); doFullBuild(projectName); - if (AjdeInteractionTestbed.VERBOSE) + if (AjdeInteractionTestbed.VERBOSE) { printBuildReport(projectName); + } } private void constructUpToDateLstFile(String pname, String configname) { @@ -148,8 +147,9 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI private void collectUpFiles(File location, File base, List<String> collectionPoint) { String contents[] = location.list(); - if (contents == null) + if (contents == null) { return; + } for (String string : contents) { File f = new File(location, string); if (f.isDirectory()) { @@ -159,8 +159,9 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI try { fileFound = f.getCanonicalPath(); String toRemove = base.getCanonicalPath(); - if (!fileFound.startsWith(toRemove)) + if (!fileFound.startsWith(toRemove)) { throw new RuntimeException("eh? " + fileFound + " " + toRemove); + } collectionPoint.add(fileFound.substring(toRemove.length() + 1));// +1 captures extra separator } catch (IOException e) { e.printStackTrace(); @@ -191,8 +192,9 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI File projectSrc = new File(testdataSrcDir + File.separatorChar + projectName + File.separatorChar + overlayDirectory); File destination = new File(getWorkingDir(), projectName); - if (AjdeInteractionTestbed.VERBOSE) + if (AjdeInteractionTestbed.VERBOSE) { System.out.println("Altering project " + projectName); + } copy(projectSrc, destination); } @@ -201,8 +203,9 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI */ protected void copy(File from, File to) { String contents[] = from.list(); - if (contents == null) + if (contents == null) { return; + } for (String string : contents) { File f = new File(from, string); File t = new File(to, string); @@ -263,10 +266,12 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI /** @return the number of relationship pairs */ protected void printModel(String projectName) throws Exception { - dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); - PrintWriter pw = new PrintWriter(System.out); - getModelFor(projectName).dumprels(pw); - pw.flush(); + if (AjdeInteractionTestbed.VERBOSE) { + dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); + PrintWriter pw = new PrintWriter(System.out); + getModelFor(projectName).dumprels(pw); + pw.flush(); + } } protected File getProjectRelativePath(String p, String filename) { diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index 5cfb4b1a7..9e6f9d0a1 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -41,7 +41,7 @@ import junit.framework.TestCase; */ public class AjdeInteractionTestbed extends TestCase { - public static boolean VERBOSE = System.getProperty("aspectj.tests.verbose","true").equalsIgnoreCase("true"); + public final static boolean VERBOSE = System.getProperty("aspectj.tests.verbose", "true").equalsIgnoreCase("true"); public static String testdataSrcDir = "../tests/multiIncremental"; protected static File sandboxDir; @@ -329,13 +329,15 @@ public class AjdeInteractionTestbed extends TestCase { * Make sure no errors have been recorded */ private void checkForErrors(AjCompiler compiler) { - MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); - if (handler.hasErrorMessages()) { - System.err.println("Build errors:"); - for (IMessage message: handler.getErrorMessages()) { - System.err.println(message); + if (AjdeInteractionTestbed.VERBOSE) { + MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); + if (handler.hasErrorMessages()) { + System.err.println("Build errors:"); + for (IMessage message : handler.getErrorMessages()) { + System.err.println(message); + } + System.err.println("---------"); } - System.err.println("---------"); } } diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java index 5e6708a2e..086c8ce95 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AnnotationProcessingTests.java @@ -14,6 +14,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.aspectj.util.FileUtil; @@ -42,7 +43,7 @@ public class AnnotationProcessingTests extends AbstractMultiProjectIncrementalAj configureProcessorOptions("ProcessorConsumer1","DemoProcessor"); configureNonStandardCompileOptions("ProcessorConsumer1", "-showWeaveInfo"); - Hashtable<String, String> javaOptions = new Hashtable<>(); + Map<String, String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); @@ -70,7 +71,7 @@ public class AnnotationProcessingTests extends AbstractMultiProjectIncrementalAj configureProcessorPath("ProcessorConsumer2", getCompilerForProjectWithName("ProcessorProject2").getCompilerConfiguration().getOutputLocationManager().getDefaultOutputLocation().toString()+File.pathSeparator+ new File(testdataSrcDir + File.separatorChar + "ProcessorProject2" + File.separatorChar + "base"+File.separatorChar+"src").toString()); - Hashtable<String, String> javaOptions = new Hashtable<>(); + Map<String, String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); @@ -108,7 +109,7 @@ public class AnnotationProcessingTests extends AbstractMultiProjectIncrementalAj configureNonStandardCompileOptions("ProcessorConsumer1", "-showWeaveInfo"); - Hashtable<String, String> javaOptions = new Hashtable<>(); + Map<String, String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java index 0efff1b99..e0a7c2437 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java @@ -131,7 +131,6 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental } public void testITIT_336147_3() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr336147_3"; initialiseProject(p); build(p); @@ -841,7 +840,6 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental } public void testDeletionAnonInnerType_278496_8() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr278496_8"; initialiseProject(p); configureNonStandardCompileOptions(p, "-Xset:minimalModel=true"); diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java index 428c037d8..c4076fc97 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java @@ -104,7 +104,6 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental * to check. */ public void testBuildingTwoProjects() { - AjdeInteractionTestbed.VERBOSE = true; String projA = "Proj64"; String projB = "Dependee"; diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java index 36be6773e..b3ae1b6c1 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java @@ -107,7 +107,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio if (javaOptionsMap != null && !javaOptionsMap.isEmpty()) return javaOptionsMap; - Hashtable<String, String> ht = new Hashtable<>(); + Map<String, String> ht = new Hashtable<>(); ht.put("org.eclipse.jdt.core.compiler.compliance", "1.5"); ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5"); ht.put("org.eclipse.jdt.core.compiler.source", "1.5"); diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 30793c396..968c37ae0 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -4,7 +4,7 @@ * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution and is available at * http://eclipse.org/legal/epl-v10.html - * + * * Contributors: * Andy Clement initial implementation * Helen Hawkins Converted to new interface (bug 148190) @@ -57,7 +57,7 @@ import org.aspectj.weaver.World; * overlays for incremental builds, that is in here. As is the ability to generate valid build configs based on a directory * structure. To support this we just need access to a sandbox directory - this sandbox is managed by the superclass (it only * assumes all builds occur in <sandboxDir>/<projectName>/ ) - * + * * The idea is you can initialize multiple projects in the sandbox and they can all be built independently, hopefully exploiting * incremental compilation. Between builds you can alter the contents of a project using the alter() method that overlays some set * of new files onto the current set (adding new files/changing existing ones) - you can then drive a new build and check it behaves @@ -66,7 +66,6 @@ import org.aspectj.weaver.World; public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { public void testIncremental_344326() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr344326"; initialiseProject(p); build(p); @@ -107,8 +106,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); // Should both indicate that Location cannot be resolved assertEquals(2,getErrorMessages(p).size()); - } - + } + public void testIncrementalITDInners4() throws Exception { String p = "prInner4"; initialiseProject(p); @@ -123,7 +122,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testIncrementalITDInners3() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "prInner3"; initialiseProject(p); build(p); @@ -176,7 +174,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa * public void testIncrementalAspectWhitespace() throws Exception { AjdeInteractionTestbed.VERBOSE = true; String p = "xxx"; * initialiseProject(p); configureNonStandardCompileOptions(p, "-showWeaveInfo"); configureShowWeaveInfoMessages(p, true); * build(p); - * + * * List weaveMessages = getWeavingMessages(p); if (weaveMessages.size() != 0) { for (Iterator iterator = * weaveMessages.iterator(); iterator.hasNext();) { Object object = iterator.next(); System.out.println(object); } } * checkWasFullBuild(); assertNoErrors(p); alter(p, "inc1"); build(p); checkWasntFullBuild(); assertNoErrors(p); } @@ -316,7 +314,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // found whilst looking at 322446 hence that is the testdata name public void testAspectInheritance_322664() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr322446_3"; initialiseProject(p); build(p); @@ -684,7 +681,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String p = "pr278255"; initialiseProject(p); build(p); - printModelAndRelationships(p); + if (AjdeInteractionTestbed.VERBOSE) { + printModelAndRelationships(p); + } IRelationshipMap irm = getModelFor(p).getRelationshipMap(); List<IRelationship> l = irm.get("=pr278255<{A.java'X`declare \\@type"); assertNotNull(l); @@ -808,7 +807,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String p = "pr266420"; initialiseProject(p); - Hashtable<String,String> javaOptions = new Hashtable<>(); + Map<String,String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); @@ -842,7 +841,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testPR265729() { - AjdeInteractionTestbed.VERBOSE = true; String lib = "pr265729_lib"; initialiseProject(lib); // addClasspathEntryChanged(lib, getProjectRelativePath(p1, @@ -896,9 +894,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // @see AsmRelationshipProvider.createIntertypeDeclaredChild() List<char[]> ptypes = binaryITDM.getParameterTypes(); - assertEquals("int", new String((char[]) ptypes.get(0))); - assertEquals("java.util.List", new String((char[]) ptypes.get(1))); - assertEquals("java.io.Serializable", new String((char[]) ptypes.get(2))); + assertEquals("int", new String(ptypes.get(0))); + assertEquals("java.util.List", new String(ptypes.get(1))); + assertEquals("java.io.Serializable", new String(ptypes.get(2))); // param names not set // List pnames = binaryITDM.getParameterNames(); @@ -910,7 +908,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testXmlConfiguredProject() { - AjdeInteractionTestbed.VERBOSE = true; String p = "xmlone"; initialiseProject(p); configureNonStandardCompileOptions(p, "-showWeaveInfo");// -xmlConfigured"); @@ -957,17 +954,17 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<String> targets = ir.getTargets(); assertEquals(1, targets.size()); System.out.println(targets.get(0)); - String handle = (String) targets.get(0); + String handle = targets.get(0); assertEquals("Expected the handle for the code node inside the constructor decl", "=261380<test{C.java[C~C?constructor-call(void test.C.<init>())", handle); } /* * A.aj package pack; public aspect A { pointcut p() : call( C.method before() : p() { // line 7 } } - * + * * C.java package pack; public class C { public void method1() { method2(); // line 6 } public void method2() { } public void * method3() { method2(); // line 13 } - * + * * } */ public void testDontLoseAdviceMarkers_pr134471() { @@ -975,14 +972,18 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false; initialiseProject("P4"); build("P4"); - Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after full build where advice is applying"); + if (AjdeInteractionTestbed.VERBOSE) { + Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after full build where advice is applying"); + } // should be 4 relationship entries // In inc1 the first advised line is 'commented out' alter("P4", "inc1"); build("P4"); checkWasntFullBuild(); - Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after inc build where first advised line is gone"); + if (AjdeInteractionTestbed.VERBOSE) { + Ajc.dumpAJDEStructureModel(getModelFor("P4"), "after inc build where first advised line is gone"); + } // should now be 2 relationship entries // This will be the line 6 entry in C.java @@ -1046,7 +1047,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasntFullBuild(); List<IMessage> msgs = getErrorMessages(p); assertEquals("error message should be 'The type C is already defined' ", "The type C is already defined", - ((IMessage) msgs.get(0)).getMessage()); + msgs.get(0).getMessage()); alter("PR148285_2", "inc2"); // type C in A.aj is commented out build("PR148285_2"); checkWasntFullBuild(); @@ -1089,7 +1090,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // class C {} public void testITDFQNames_pr252702() { String p = "itdfq"; - AjdeInteractionTestbed.VERBOSE = true; initialiseProject(p); build(p); AsmManager model = getModelFor(p); @@ -1141,7 +1141,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testNPEIncremental_pr262218() { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr262218"; initialiseProject(p); build(p); @@ -1154,7 +1153,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testDeclareAnnotationNPE_298504() { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr298504"; initialiseProject(p); build(p); @@ -1171,7 +1169,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testIncrementalAnnoStyle_pr286341() { - AjdeInteractionTestbed.VERBOSE = true; String base = "pr286341_base"; initialiseProject(base); build(base); @@ -1214,7 +1211,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testBuildingBrokenCode_pr263323() { - AjdeInteractionTestbed.VERBOSE = true; String p = "brokenCode"; initialiseProject(p); build(p); @@ -1236,7 +1232,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa */ public void testItdProb() { - AjdeInteractionTestbed.VERBOSE = true; String p = "itdprob"; initialiseProject(p); build(p); @@ -1251,7 +1246,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /* * public void testGenericITD_pr262257() throws IOException { String p = "pr262257"; initialiseProject(p); build(p); * checkWasFullBuild(); - * + * * dumptree(getModelFor(p).getHierarchy().getRoot(), 0); PrintWriter pw = new PrintWriter(System.out); * getModelFor(p).dumprels(pw); pw.flush(); } */ @@ -1414,7 +1409,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testIncrementalBuildsWithItds_pr259528() { String p = "pr259528"; - AjdeInteractionTestbed.VERBOSE = true; initialiseProject(p); build(p); checkWasFullBuild(); @@ -1716,7 +1710,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<IProgramElement> kids = start.getChildren(); if (kids != null) { for (IProgramElement kid : kids) { - IProgramElement found = getChild((IProgramElement) kid, name); + IProgramElement found = getChild(kid, name); if (found != null) { return found; } @@ -1862,11 +1856,11 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa */ /* * public void testProblemCopyingResources_pr138171() { initialiseProject("PR138171"); - * + * * File f=getProjectRelativePath("PR138171","res.txt"); Map m = new HashMap(); m.put("res.txt",f); * AjdeInteractionTestbed.MyProjectPropertiesAdapter .getInstance().setSourcePathResources(m); build("PR138171"); File f2 = * getProjectOutputRelativePath("PR138171","res.txt"); boolean successful = f2.setReadOnly(); - * + * * alter("PR138171","inc1"); AjdeInteractionTestbed.MyProjectPropertiesAdapter .getInstance().setSourcePathResources(m); * build("PR138171"); List msgs = MyTaskListManager.getErrorMessages(); assertTrue("there should be one message but there are " * +(msgs==null?0:msgs.size())+":\n"+msgs,msgs!=null && msgs.size()==1); IMessage msg = (IMessage)msgs.get(0); String exp = @@ -1918,7 +1912,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("P2"); checkWasntFullBuild(); } - + public void testBuildingBrokenCode_pr240360() { initialiseProject("pr240360"); // configureNonStandardCompileOptions("pr240360","-proceedOnError"); @@ -2114,7 +2108,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); Enumeration<? extends ZipEntry> e = zf.entries(); while (e.hasMoreElements()) { - ZipEntry ze = (ZipEntry) e.nextElement(); + ZipEntry ze = e.nextElement(); String n = ze.getName(); if (n.endsWith(".class")) { n = n.replace('/', '.'); @@ -2170,8 +2164,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa assertFalse(typeA.isMissing()); List<ResolvedMember> viaIteratorList = getThemAll(typeA.getMethods(wantGenerics, true)); List<ResolvedMember> directlyList = typeA.getMethodsWithoutIterator(true, true, wantGenerics); - Collections.sort(viaIteratorList, new ResolvedMemberComparator()); - Collections.sort(directlyList, new ResolvedMemberComparator()); + viaIteratorList.sort(new ResolvedMemberComparator()); + directlyList.sort(new ResolvedMemberComparator()); compare(viaIteratorList, directlyList, name); // System.out.println(toString(viaIteratorList, directlyList, genericsAware)); } @@ -2373,7 +2367,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * The C.java file modified in this test has an inner class - this means the inner class has a this$0 field and <init>(C) ctor * to watch out for when checking for structural changes - * + * */ public void testStateManagement3() { File binDirForInterproject1 = new File(getFile("interprojectdeps1", "bin")); @@ -2398,7 +2392,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * The C.java file modified in this test has an inner class - which has two ctors - this checks how they are mangled with an * instance of C. - * + * */ public void testStateManagement4() { File binDirForInterproject2 = new File(getFile("interprojectdeps2", "bin")); @@ -2423,7 +2417,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * The C.java file modified in this test has an inner class - it has two ctors but also a reference to C.this in it - which will * give rise to an accessor being created in C - * + * */ public void testStateManagement5() { File binDirForInterproject3 = new File(getFile("interprojectdeps3", "bin")); @@ -2713,7 +2707,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size(); assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1); - String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); + String name = AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java")); } @@ -2729,7 +2723,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size(); assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1); - String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); + String name = AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0); assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java")); } @@ -2770,13 +2764,13 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<IMessage> errors = getErrorMessages("PR119882"); assertTrue("Should be at least one error, but got none", errors.size() == 1); assertEquals("error message should be 'i cannot be resolved to a variable' ", "i cannot be resolved to a variable", - ((IMessage) errors.get(0)).getMessage()); + errors.get(0).getMessage()); alter("PR119882", "inc2"); build("PR119882"); assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR119882"), getCompilerErrorMessages("PR119882").isEmpty()); assertEquals("error message should be 'i cannot be resolved to a variable' ", "i cannot be resolved to a variable", - ((IMessage) errors.get(0)).getMessage()); + errors.get(0).getMessage()); } @@ -2842,8 +2836,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<IMessage> secondBuildMessages = getWeavingMessages("pr128655"); // check they are the same for (int i = 0; i < firstBuildMessages.size(); i++) { - IMessage m1 = (IMessage) firstBuildMessages.get(i); - IMessage m2 = (IMessage) secondBuildMessages.get(i); + IMessage m1 = firstBuildMessages.get(i); + IMessage m2 = secondBuildMessages.get(i); if (!m1.toString().equals(m2.toString())) { System.err.println("Message during first build was: " + m1); System.err.println("Message during second build was: " + m1); @@ -2866,8 +2860,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa List<IMessage> secondBuildMessages = getWeavingMessages("pr128655_2"); // check they are the same for (int i = 0; i < firstBuildMessages.size(); i++) { - IMessage m1 = (IMessage) firstBuildMessages.get(i); - IMessage m2 = (IMessage) secondBuildMessages.get(i); + IMessage m1 = firstBuildMessages.get(i); + IMessage m2 = secondBuildMessages.get(i); if (!m1.toString().equals(m2.toString())) { System.err.println("Message during first build was: " + m1); System.err.println("Message during second build was: " + m1); @@ -2909,7 +2903,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testIncrementalIntelligence_Scenario01() { - AjdeInteractionTestbed.VERBOSE = true; initialiseProject("Project1"); initialiseProject("Project2"); configureNewProjectDependency("Project2", "Project1"); @@ -2972,37 +2965,37 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa * public void testPrReducingDependentBuilds_001_221427() { AjdeInteractionTestbed.VERBOSE=true; * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_1"); initialiseProject("P221427_2"); * configureNewProjectDependency("P221427_2","P221427_1"); - * + * * build("P221427_1"); build("P221427_2"); alter("P221427_1","inc1"); // rename private class in super project * MyStateListener.reset(); build("P221427_1"); build("P221427_2"); - * + * * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_1","bin"))); * assertTrue("There should be state for project P221427_1",ajs!=null); * //System.out.println(MyStateListener.getInstance().getDecisions()); checkWasntFullBuild(); * assertTrue("Should be one structural change but there were "+ ajs.getNumberOfStructuralChangesSinceLastFullBuild(), * ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); - * + * * } - * + * * // Case002: changing a class to final that is extended in a dependent project public void * testPrReducingDependentBuilds_002_221427() { AjdeInteractionTestbed.VERBOSE=true; * IncrementalStateManager.debugIncrementalStates=true; initialiseProject("P221427_3"); initialiseProject("P221427_4"); * configureNewProjectDependency("P221427_4","P221427_3"); - * + * * build("P221427_3"); build("P221427_4"); // build OK, type in super project is non-final alter("P221427_3","inc1"); // change * class declaration in super-project to final MyStateListener.reset(); build("P221427_3"); build("P221427_4"); // build FAIL, * type in super project is now final - * + * * AjState ajs = IncrementalStateManager.findStateManagingOutputLocation(new File(getFile("P221427_3","bin"))); * assertTrue("There should be state for project P221427_3",ajs!=null); * System.out.println(MyStateListener.getInstance().getDecisions()); - * + * * List errors = getErrorMessages("P221427_4"); if (errors.size()!=1) { if (errors.size()==0) * fail("Expected error about not being able to extend final class"); for (Iterator iterator = errors.iterator(); * iterator.hasNext();) { Object object = (Object) iterator.next(); System.out.println(object); } * fail("Expected 1 error but got "+errors.size()); } // assertTrue("Shouldn't be one structural change but there were "+ // * ajs.getNumberOfStructuralChangesSinceLastFullBuild(), // ajs.getNumberOfStructuralChangesSinceLastFullBuild()==1); - * + * * } */ // test for comment #6 - simulates AJDT core builder test testBug99133a - @@ -3566,7 +3559,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa build("PR154054"); checkWasntFullBuild(); } - + public void testIncrementalBuildAdviceChange_456801() throws Exception { initialiseProject("456801"); build("456801"); @@ -3614,7 +3607,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testPR164384_1() { initialiseProject("PR164384"); - Hashtable<String, String> javaOptions = new Hashtable<>(); + Map<String, String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.6"); @@ -3627,7 +3620,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa assertTrue("There should be no errors:\n" + errors, errors.isEmpty()); } else { String expectedError = "Java 6.0 compliance level is unsupported"; - String found = ((IMessage) errors.get(0)).getMessage(); + String found = errors.get(0).getMessage(); assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, expectedError, found); // This is because the 'Java 6.0 compliance' error is an 'error' @@ -3646,7 +3639,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testPR164384_2() { initialiseProject("PR164384"); - Hashtable<String, String> javaOptions = new Hashtable<>(); + Map<String, String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.5"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.5"); @@ -3658,7 +3651,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa assertTrue("There should be no errors:\n" + errors, errors.isEmpty()); } else { String expectedError = "Java 6.0 compliance level is unsupported"; - String found = ((IMessage) errors.get(0)).getMessage(); + String found = errors.get(0).getMessage(); assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, expectedError, found); // This is because the 'Java 6.0 compliance' error is an 'error' @@ -3676,7 +3669,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa public void testPR164384_3() { initialiseProject("PR164384"); - Hashtable<String, String> javaOptions = new Hashtable<>(); + Map<String, String> javaOptions = new Hashtable<>(); javaOptions.put("org.eclipse.jdt.core.compiler.compliance", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform", "1.6"); javaOptions.put("org.eclipse.jdt.core.compiler.source", "1.5"); @@ -3689,7 +3682,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa assertTrue("There should be no errros:\n" + errors, errors.isEmpty()); } else { String expectedError = "Java 6.0 compliance level is unsupported"; - String found = ((IMessage) errors.get(0)).getMessage(); + String found = errors.get(0).getMessage(); assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found, expectedError, found); // This is because the 'Java 6.0 compliance' error is an 'error' @@ -3734,7 +3727,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // warning about cant change parents of Object is fine public void testInpathHandles_271201() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "inpathHandles"; initialiseProject(p); @@ -3766,7 +3758,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // warning about cant change parents of Object is fine public void testInpathHandles_IncrementalCompilation_271201() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "inpathHandles"; initialiseProject(p); @@ -3802,7 +3793,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testInpathHandles_WithInpathMap_271201() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "inpathHandles"; initialiseProject(p); @@ -3850,7 +3840,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } public void testInpathHandles_IncrementalCompilation_RemovingInpathEntries_271201() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "inpathHandles2"; initialiseProject(p); @@ -3902,7 +3891,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa /** * Retrieve program elements related to this one regardless of the relationship. A JUnit assertion is made that the number that * the 'expected' number are found. - * + * * @param programElement Program element whose related elements are to be found * @param expected the number of expected related elements */ @@ -3921,7 +3910,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa private IProgramElement getFirstRelatedElement(AsmManager model, IProgramElement programElement) { List<String> rels = getRelatedElements(model, programElement, 1); - return model.getHierarchy().findElementForHandle((String) rels.get(0)); + return model.getHierarchy().findElementForHandle(rels.get(0)); } private List<String> getRelatedElements(AsmManager model, IProgramElement advice) { @@ -3953,7 +3942,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } } List<IProgramElement> kids = ipe.getChildren(); - for (IProgramElement kid: kids) { + for (IProgramElement kid: kids) { IProgramElement found = findAdvice(kid, whichOne); if (found != null) { return found; diff --git a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java index b18d9a5f7..550ff759a 100644 --- a/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java +++ b/tests/src/test/java/org/aspectj/systemtest/model/ModelTestCase.java @@ -143,8 +143,7 @@ public abstract class ModelTestCase extends XMLBasedAjcTestCase { while ((expectedLine = expect.readLine()) != null) { fileContents.add(expectedLine); } - List<String> expectedFileContents = new ArrayList<>(); - expectedFileContents.addAll(fileContents); + List<String> expectedFileContents = new ArrayList<>(fileContents); // Load the file with the output from this test run BufferedReader found = new BufferedReader(new FileReader(new File(modelOutput))); diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml index 936ec50d3..5565e91b7 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml @@ -511,6 +511,7 @@ <line text="Hello World!" /> </stdout> <stderr> + <line text="Archived non-system classes are disabled" vm="14+"/> <line text="TraceFactory.instance=" /> </stderr> </ant> diff --git a/util/src/main/java/org/aspectj/util/FileUtil.java b/util/src/main/java/org/aspectj/util/FileUtil.java index 976c3ccbc..588a46c43 100644 --- a/util/src/main/java/org/aspectj/util/FileUtil.java +++ b/util/src/main/java/org/aspectj/util/FileUtil.java @@ -39,7 +39,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.zip.ZipEntry; @@ -710,7 +709,7 @@ public class FileUtil { if ((null != srcDir) && srcDir.canRead()) { listFiles(srcDir, result, fileFilter); } - return result.toArray(new File[result.size()]); + return result.toArray(new File[0]); } /** @@ -1294,7 +1293,7 @@ public class FileUtil { * @param List sink the List for String entries of the form {sourcePath}:line:column * @return String error if any, or add String entries to sink */ - public static String lineSeek(String sought, String sourcePath, boolean listAll, ArrayList<String> sink) { + public static String lineSeek(String sought, String sourcePath, boolean listAll, List<String> sink) { if (LangUtil.isEmpty(sought) || LangUtil.isEmpty(sourcePath)) { return "nothing sought"; } diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 98f53e3c8..edfc48f70 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -359,7 +359,7 @@ public class LangUtil { if (null == input) { return Collections.emptyList(); } - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); if (LangUtil.isEmpty(delim) || (!input.contains(delim))) { result.add(input.trim()); @@ -741,7 +741,7 @@ public class LangUtil { final int sinkLength = (null == sink ? 0 : sink.length); final int resultSize; - ArrayList<Object> result = null; + List<Object> result = null; if (0 == sourceLength) { resultSize = 0; } else { @@ -1000,8 +1000,7 @@ public class LangUtil { if ((null == array) || (1 > array.length)) { return Collections.emptyList(); } - ArrayList<T> list = new ArrayList<>(); - list.addAll(Arrays.asList(array)); + List<T> list = new ArrayList<>(Arrays.asList(array)); return list; } diff --git a/util/src/main/java/org/aspectj/util/UtilClassLoader.java b/util/src/main/java/org/aspectj/util/UtilClassLoader.java index b4d09533f..2c488bc3a 100644 --- a/util/src/main/java/org/aspectj/util/UtilClassLoader.java +++ b/util/src/main/java/org/aspectj/util/UtilClassLoader.java @@ -22,7 +22,6 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; /** @@ -40,7 +39,7 @@ public class UtilClassLoader extends URLClassLoader { super(urls); LangUtil.throwIaxIfNotAssignable(dirs, File.class, "dirs"); this.urlsForDebugString = urls; - ArrayList<File> dcopy = new ArrayList<>(); + List<File> dcopy = new ArrayList<>(); if (!LangUtil.isEmpty(dirs)) { dcopy.addAll(Arrays.asList(dirs)); diff --git a/util/src/test/java/org/aspectj/util/FileUtilTest.java b/util/src/test/java/org/aspectj/util/FileUtilTest.java index 7936914fb..29cd246e4 100644 --- a/util/src/test/java/org/aspectj/util/FileUtilTest.java +++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java @@ -62,7 +62,7 @@ public class FileUtilTest extends TestCase { * @throws AssertionFailedError if any names are not in dir */ public static String[] dirContains(File dir, final String[] filenames) { - final ArrayList<String> sought = new ArrayList<>(LangUtil.arrayAsList(filenames)); + final List<String> sought = new ArrayList<>(LangUtil.arrayAsList(filenames)); FilenameFilter filter = new FilenameFilter() { public boolean accept(File d, String name) { return !sought.remove(name); @@ -188,7 +188,7 @@ public class FileUtilTest extends TestCase { } /** List of File files or directories to delete when exiting */ - final ArrayList<File> tempFiles; + final List<File> tempFiles; public FileUtilTest(String s) { super(s); @@ -388,7 +388,7 @@ public class FileUtilTest extends TestCase { } public void testRandomFileString() { - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); for (int i = 0; i < 1000; i++) { String s = FileUtil.randomFileString(); if (results.contains(s)) { @@ -462,7 +462,7 @@ public class FileUtilTest extends TestCase { List<String> sourceList = new ArrayList<>(); sourceList.add(file.getPath()); - final ArrayList<String> errors = new ArrayList<>(); + final List<String> errors = new ArrayList<>(); final PrintStream errorSink = new PrintStream(System.err, true) { public void println(String error) { errors.add(error); @@ -502,14 +502,13 @@ public class FileUtilTest extends TestCase { tempFiles.add(file); } // now test - final ArrayList<String> errors = new ArrayList<>(); + final List<String> errors = new ArrayList<>(); final PrintStream errorSink = new PrintStream(System.err, true) { public void println(String error) { errors.add(error); } }; - List<String> sourceList = new ArrayList<>(); - sourceList.addAll(Arrays.asList(sources)); + List<String> sourceList = new ArrayList<>(Arrays.asList(sources)); sourceList = Collections.unmodifiableList(sourceList); for (int k = 0; k < sources.length; k++) { List<String> result = FileUtil.lineSeek("" + k, sourceList, true, errorSink); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java index b91496ea7..5f2032704 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -1785,7 +1785,7 @@ public class AtAjAttributes { } // sort by index - Collections.sort(arguments, new Comparator<MethodArgument>() { + arguments.sort(new Comparator<MethodArgument>() { public int compare(MethodArgument mo, MethodArgument mo1) { if (mo.indexOnStack == mo1.indexOnStack) { return 0; @@ -1905,7 +1905,7 @@ public class AtAjAttributes { ignores.add(formalBinding.getName()); } } - pointcut.m_ignoreUnboundBindingForNames = ignores.toArray(new String[ignores.size()]); + pointcut.m_ignoreUnboundBindingForNames = ignores.toArray(new String[0]); } /** diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java index bbad8ed6a..edf7a0c48 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -923,8 +923,7 @@ class BcelClassWeaver implements IClassWeaver { return false; // nothing to do } - Set<DeclareAnnotation> unusedDecams = new HashSet<>(); - unusedDecams.addAll(decaMs); + Set<DeclareAnnotation> unusedDecams = new HashSet<>(decaMs); // These methods may have been targeted with declare annotation. Example: ITD on an interface // where the top most implementor gets a real method. The top most implementor method @@ -1413,8 +1412,7 @@ class BcelClassWeaver implements IClassWeaver { List<BcelField> fields = clazz.getFieldGens(); if (fields != null) { - Set<DeclareAnnotation> unusedDecafs = new HashSet<>(); - unusedDecafs.addAll(decafs); + Set<DeclareAnnotation> unusedDecafs = new HashSet<>(decafs); for (BcelField field : fields) { if (!field.getName().startsWith(NameMangler.PREFIX)) { // Single first pass @@ -2593,7 +2591,7 @@ class BcelClassWeaver implements IClassWeaver { } private void weaveInAddedMethods() { - Collections.sort(addedLazyMethodGens, new Comparator<LazyMethodGen>() { + addedLazyMethodGens.sort(new Comparator<LazyMethodGen>() { public int compare(LazyMethodGen aa, LazyMethodGen bb) { int i = aa.getName().compareTo(bb.getName()); if (i != 0) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java index 3e9ac1b75..41b1f3fa6 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -399,7 +398,7 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { if (pointcuts.size() == 0) { this.pointcuts = ResolvedPointcutDefinition.NO_POINTCUTS; } else { - this.pointcuts = pointcuts.toArray(new ResolvedPointcutDefinition[pointcuts.size()]); + this.pointcuts = pointcuts.toArray(new ResolvedPointcutDefinition[0]); } resolveAnnotationDeclares(l); @@ -771,12 +770,8 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { GenericSignature.FormalTypeParameter[] extraFormals = getFormalTypeParametersFromOuterClass(); if (extraFormals.length > 0) { List<FormalTypeParameter> allFormals = new ArrayList<>(); - for (FormalTypeParameter formalTypeParameter : formalsForResolution) { - allFormals.add(formalTypeParameter); - } - for (FormalTypeParameter extraFormal : extraFormals) { - allFormals.add(extraFormal); - } + Collections.addAll(allFormals, formalsForResolution); + Collections.addAll(allFormals, extraFormals); formalsForResolution = new GenericSignature.FormalTypeParameter[allFormals.size()]; allFormals.toArray(formalsForResolution); } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java index 61b0bf746..7230ecd7e 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java @@ -17,7 +17,6 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java index 1fb2812bb..62674dedf 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -167,11 +167,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { } String tname = target.getName(); String pname = newParent.getName(); - List<String> newparents = declareParentsMap.get(tname); - if (newparents == null) { - newparents = new ArrayList<>(); - declareParentsMap.put(tname, newparents); - } + List<String> newparents = declareParentsMap.computeIfAbsent(tname, k -> new ArrayList<>()); newparents.add(pname); AsmRelationshipProvider.addRelationship(model, weaver.getLazyClassGen().getType(), munger, declaringAspect); } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java index a6809f26f..110d58c88 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java @@ -548,7 +548,7 @@ public class BcelWeaver { // this code may need // a bit of alteration... - Collections.sort(shadowMungerList, new Comparator<ShadowMunger>() { + shadowMungerList.sort(new Comparator<ShadowMunger>() { public int compare(ShadowMunger sm1, ShadowMunger sm2) { if (sm1.getSourceLocation() == null) { return (sm2.getSourceLocation() == null ? 0 : 1); @@ -946,7 +946,7 @@ public class BcelWeaver { manifest = new Manifest(); - Attributes attributes = manifest.getMainAttributes(); + Map attributes = manifest.getMainAttributes(); attributes.put(Name.MANIFEST_VERSION, WEAVER_MANIFEST_VERSION); attributes.put(CREATED_BY, WEAVER_CREATED_BY); } diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java index cd378dbbf..76acc6e7f 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java @@ -352,12 +352,12 @@ public class ClassPathManager { FileSystem fs = null; try { if (LangUtil.is19VMOrGreater()) { - HashMap<String, String> env = new HashMap<>(); + Map<String, String> env = new HashMap<>(); env.put("java.home", jdkHome); fs = FileSystems.newFileSystem(JRT_URI, env); } else { URLClassLoader loader = new URLClassLoader(new URL[] { jrtPath }); - HashMap<String, ?> env = new HashMap<>(); + Map<String, ?> env = new HashMap<>(); fs = FileSystems.newFileSystem(JRT_URI, env, loader); } state = new JImageState(jrtFsPath, fs); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java index 46f0958e6..f2e61c565 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java @@ -1260,7 +1260,7 @@ public final class LazyClassGen { lists.add(list); List<Map.Entry<BcelShadow, Field>> entries = new ArrayList<>(tjpFields.entrySet()); - Collections.sort(entries, new Comparator<Map.Entry<BcelShadow, Field>>() { + entries.sort(new Comparator<Map.Entry<BcelShadow, Field>>() { @Override public int compare(Map.Entry<BcelShadow, Field> a, Map.Entry<BcelShadow, Field> b) { return (a.getValue()).getName().compareTo((b.getValue()).getName()); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java index 3ab0c5daf..7bac02dad 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -336,7 +336,7 @@ public final class LazyMethodGen implements Traceable { public AnnotationAJ[] getAnnotations() { initialize(); if (memberView == null && newAnnotations!=null && newAnnotations.size()!=0) { - return newAnnotations.toArray(new AnnotationAJ[newAnnotations.size()]); + return newAnnotations.toArray(new AnnotationAJ[0]); } return null; } @@ -1359,7 +1359,7 @@ public final class LazyMethodGen implements Traceable { } private void addExceptionHandlers(MethodGen gen, Map<InstructionHandle, InstructionHandle> map, - LinkedList<ExceptionRange> exnList) { + Iterable<ExceptionRange> exnList) { // now add exception handlers for (ExceptionRange r : exnList) { if (r.isEmpty()) { @@ -1547,7 +1547,7 @@ public final class LazyMethodGen implements Traceable { // but I don't trust the only implementation, TreeSet, to do the right // thing. - /* private */static void insertHandler(ExceptionRange fresh, LinkedList<ExceptionRange> l) { + /* private */static void insertHandler(ExceptionRange fresh, List<ExceptionRange> l) { // Old implementation, simply: l.add(0,fresh); for (ListIterator<ExceptionRange> iter = l.listIterator(); iter.hasNext();) { ExceptionRange r = iter.next(); diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java b/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java index ebcb4251c..eaebad695 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/Range.java @@ -12,8 +12,6 @@ package org.aspectj.weaver.bcel; -import java.util.Iterator; - import org.aspectj.apache.bcel.generic.Instruction; import org.aspectj.apache.bcel.generic.InstructionConstants; import org.aspectj.apache.bcel.generic.InstructionHandle; diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java index 966699c04..d25a4b1ee 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ShadowRange.java @@ -12,8 +12,6 @@ package org.aspectj.weaver.bcel; -import java.util.Iterator; - import org.aspectj.apache.bcel.generic.Instruction; import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionFactory; diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java index 44ac48b9f..e1e297ad1 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/Utility.java @@ -18,7 +18,6 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collections; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.Constants; diff --git a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java index e49988a89..8d912a317 100644 --- a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java +++ b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java @@ -253,7 +253,7 @@ public class SimpleAOPParser { private static void traverse(SimpleAOPParser sap, LightXMLParser xml) throws Exception { sap.startElement(xml.getName(), xml.getAttributes()); - ArrayList childrens = xml.getChildrens(); + Iterable childrens = xml.getChildrens(); for (Object children : childrens) { LightXMLParser child = (LightXMLParser) children; traverse(sap, child); diff --git a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java index c9f1ecffc..e7d6ff63e 100644 --- a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java @@ -19,7 +19,6 @@ import java.util.Map; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.bridge.IMessageHandler; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.Dump.IVisitor; import org.aspectj.weaver.ICrossReferenceHandler; import org.aspectj.weaver.ReferenceType; diff --git a/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java b/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java index 80cfb6de7..cf9bb1b94 100644 --- a/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java +++ b/weaver/src/main/java/org/aspectj/weaver/model/AsmRelationshipProvider.java @@ -17,7 +17,6 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; diff --git a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java index f617f49da..0edd1d40e 100644 --- a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java +++ b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java @@ -17,7 +17,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; -import java.util.Iterator; import java.util.Set; import org.aspectj.lang.annotation.Aspect; diff --git a/weaver/src/main/java/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java b/weaver/src/main/java/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java index cb05b10e0..32dba3d90 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/cache/AbstractIndexedFileCacheBacking.java @@ -71,7 +71,7 @@ public abstract class AbstractIndexedFileCacheBacking extends AbstractFileCacheB if (matches.isEmpty()) { return EMPTY_KEYS; } else { - return matches.toArray(new String[matches.size()]); + return matches.toArray(new String[0]); } } diff --git a/weaver/src/main/java/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java b/weaver/src/main/java/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java index b9031cbae..e2d8288c4 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/cache/DefaultCacheKeyResolver.java @@ -15,7 +15,6 @@ package org.aspectj.weaver.tools.cache; import java.net.URL; import java.net.URLClassLoader; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.zip.CRC32; diff --git a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java index 2c99ee29f..fbe505292 100644 --- a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java @@ -191,13 +191,13 @@ public class ReferenceTypeTestCase extends TestCase { public void testAssignable02() { List list = new ArrayList(); - ArrayList arraylist = null; + List arraylist = null; List<String> listOfString = new ArrayList<>(); List<?> listOfSomething = new ArrayList<Integer>(); - ArrayList<?> arrayListOfSomething = null; + List<?> arrayListOfSomething = null; List<Number> listOfNumber = null; ArrayList<Number> arrayListOfNumber = null; - ArrayList<? extends Number> arrayListOfSomethingNumberish = null; + List<? extends Number> arrayListOfSomethingNumberish = null; List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>(); List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>(); List<Integer> listOfInteger = new ArrayList<>(); @@ -274,14 +274,14 @@ public class ReferenceTypeTestCase extends TestCase { public void testAssignable03_method_m2() { List list = new ArrayList(); - ArrayList arraylist = null; + List arraylist = null; List<String> listOfString = new ArrayList<>(); List<?> listOfSomething = new ArrayList<Integer>(); - ArrayList<?> arrayListOfSomething = null; + List<?> arrayListOfSomething = null; List<Number> listOfNumber = null; - ArrayList<Number> arrayListOfNumber = null; - ArrayList<Integer> arrayListOfInteger = null; - ArrayList<? extends Number> arrayListOfSomethingNumberish = null; + List<Number> arrayListOfNumber = null; + List<Integer> arrayListOfInteger = null; + List<? extends Number> arrayListOfSomethingNumberish = null; List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>(); List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>(); List<Integer> listOfInteger = new ArrayList<>(); @@ -364,15 +364,15 @@ public class ReferenceTypeTestCase extends TestCase { ArrayList arraylist = null; List<String> listOfString = new ArrayList<>(); List<?> listOfSomething = new ArrayList<Integer>(); - ArrayList<?> arrayListOfSomething = null; + List<?> arrayListOfSomething = null; List<Number> listOfNumber = null; - ArrayList<Number> arrayListOfNumber = null; + List<Number> arrayListOfNumber = null; ArrayList<Integer> arrayListOfInteger = null; - ArrayList<? extends Number> arrayListOfSomethingNumberish = null; + List<? extends Number> arrayListOfSomethingNumberish = null; List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>(); List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>(); List<Integer> listOfInteger = new ArrayList<>(); - ArrayList arrayList = null; + List arrayList = null; ArrayList<String> arrayListOfString; ArrayList<Integer> arraylistOfInteger; // interfaces too List<? extends A,B> @@ -477,18 +477,18 @@ public class ReferenceTypeTestCase extends TestCase { public void testAssignable03_method_m4() { List list = new ArrayList(); - ArrayList arraylist = null; + List arraylist = null; List<String> listOfString = new ArrayList<>(); List<?> listOfSomething = new ArrayList<Integer>(); - ArrayList<?> arrayListOfSomething = null; + List<?> arrayListOfSomething = null; List<Number> listOfNumber = null; - ArrayList<Number> arrayListOfNumber = null; - ArrayList<? extends Number> arrayListOfSomethingNumberish = null; + List<Number> arrayListOfNumber = null; + List<? extends Number> arrayListOfSomethingNumberish = null; List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>(); List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>(); List<Integer> listOfInteger = new ArrayList<>(); - ArrayList<String> arrayListOfString; - ArrayList<Integer> arraylistOfInteger; + List<String> arrayListOfString; + List<Integer> arraylistOfInteger; // interfaces too List<? extends A,B> ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;"); @@ -599,8 +599,7 @@ public class ReferenceTypeTestCase extends TestCase { // ReferenceType.r = 0; long stime = System.nanoTime(); for (int j = 0; j < 10; j++) { - List objects2 = new ArrayList(); - objects2.addAll(objects); + List objects2 = new ArrayList(objects); PartialOrder.sort(objects2); } long etime = System.nanoTime(); diff --git a/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java b/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java index 067e12a4c..bbcbbd170 100644 --- a/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/TypeXTestCase.java @@ -14,7 +14,6 @@ package org.aspectj.weaver; import org.aspectj.testing.util.TestUtil; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.bcel.BcelWorld; import junit.framework.TestCase; diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java index a9d1fe9b4..ea5037e2c 100644 --- a/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java @@ -80,12 +80,10 @@ public class AroundWeaveTestCase extends WeaveTestCase { private void aroundTestAndOthers(String outName, final boolean matchOnlyPrintln) throws IOException { - - List<ShadowMunger> l = new ArrayList<>(); - // the afterReturning was taken out to avoid circular advice dependency + // the afterReturning was taken out to avoid circular advice dependency - l.addAll(makeAdviceAll("before", matchOnlyPrintln)); + List<ShadowMunger> l = new ArrayList<>(makeAdviceAll("before", matchOnlyPrintln)); //l.addAll(makeAdviceAll("afterReturning", matchOnlyPrintln)); l.add(makeAroundMunger(matchOnlyPrintln)); diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index ea276614c..0c5cfd860 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -18,7 +18,6 @@ import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessage.Kind; import org.aspectj.bridge.IMessageHandler; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.WeaverTestCase; diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java index 05291af1f..c848bc4c9 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java @@ -10,7 +10,6 @@ package org.aspectj.weaver.patterns; import org.aspectj.bridge.AbortException; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.ResolvedType; diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java index 5181efcf6..a89268cf9 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java @@ -17,7 +17,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.StringTokenizer; @@ -286,8 +285,7 @@ public class Java15PointcutExpressionTest extends TestCase { tps[parameterNumber].getAnnotationPattern().toString(); // parameter type annotation checking - Set<String> expected = new HashSet<>(); - expected.addAll(mpnv.getParameterTypeAnnotations()); + Set<String> expected = new HashSet<>(mpnv.getParameterTypeAnnotations()); StringTokenizer st = new StringTokenizer(expectedParameterTypeAnnotations==null?"":expectedParameterTypeAnnotations); while (st.hasMoreTokens()) { @@ -305,8 +303,7 @@ public class Java15PointcutExpressionTest extends TestCase { } // parameter annotation checking - expected = new HashSet<>(); - expected.addAll(mpnv.getParameterAnnotations()); + expected = new HashSet<>(mpnv.getParameterAnnotations()); st = new StringTokenizer(expectedParameterAnnotations==null?"":expectedParameterAnnotations); while (st.hasMoreTokens()) { diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java index 8d910baf5..bd192c78c 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java @@ -11,8 +11,6 @@ * ******************************************************************/ package org.aspectj.weaver.tools; -import org.aspectj.util.LangUtil; - import junit.framework.TestCase; /** diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java index d98d1e30e..ccf8e560b 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutExpressionTest.java @@ -14,8 +14,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import org.aspectj.util.LangUtil; - import junit.framework.TestCase; public class PointcutExpressionTest extends TestCase { diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java index 589fd6c9b..cf10b3662 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java @@ -17,7 +17,6 @@ import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessage.Kind; import org.aspectj.bridge.IMessageHandler; -import org.aspectj.util.LangUtil; import org.aspectj.weaver.patterns.PatternParser; import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.patterns.PointcutRewriter; diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java index 0096b5482..402fe4e27 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/TypePatternMatcherTest.java @@ -13,8 +13,6 @@ package org.aspectj.weaver.tools; import java.util.HashMap; import java.util.Map; -import org.aspectj.util.LangUtil; - import junit.framework.TestCase; public class TypePatternMatcherTest extends TestCase { |