diff options
author | Jay Arthanareeswaran | 2020-07-02 04:17:02 +0000 |
---|---|---|
committer | Jay Arthanareeswaran | 2020-07-15 14:36:12 +0000 |
commit | c1c989f6c7f6d8d058bbbf089b250ca1c3d327f1 (patch) | |
tree | 9937f7e275f26014c40f868cc9f09da304e122b1 | |
parent | d4dd2c08f335f58c58ceac6457aab5c0859ce7a3 (diff) | |
download | eclipse.jdt.core-c1c989f6c7f6d8d058bbbf089b250ca1c3d327f1.tar.gz eclipse.jdt.core-c1c989f6c7f6d8d058bbbf089b250ca1c3d327f1.tar.xz eclipse.jdt.core-c1c989f6c7f6d8d058bbbf089b250ca1c3d327f1.zip |
Bug 564853 - Replace Vector with ArrayList
Change-Id: Ia8b7bbcb7150c80e5bf01cd61979af6eb1339e7d
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
19 files changed, 272 insertions, 280 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java index 1938645b43..cec546b49a 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java @@ -25,7 +25,6 @@ import java.util.Collections; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; -import java.util.Vector; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClasspathEntry; @@ -75,25 +74,25 @@ public class BuilderTests extends TestCase { String expectingOutput, String expectedError) { TestVerifier verifier = new TestVerifier(false); - Vector classpath = new Vector(5); + ArrayList<String> classpath = new ArrayList<>(5); IPath workspacePath = env.getWorkspaceRootPath(); - classpath.addElement(workspacePath.append(env.getOutputLocation(projectPath)).toOSString()); + classpath.add(workspacePath.append(env.getOutputLocation(projectPath)).toOSString()); IClasspathEntry[] cp = env.getClasspath(projectPath); for (int i = 0; i < cp.length; i++) { IPath c = cp[i].getPath(); String ext = c.getFileExtension(); if (ext != null && (ext.equals("zip") || ext.equals("jar"))) { //$NON-NLS-1$ //$NON-NLS-2$ if (c.getDevice() == null) { - classpath.addElement(workspacePath.append(c).toOSString()); + classpath.add(workspacePath.append(c).toOSString()); } else { - classpath.addElement(c.toOSString()); + classpath.add(c.toOSString()); } } } - verifier.execute(className, (String[]) classpath.toArray(new String[0])); + verifier.execute(className, classpath.toArray(new String[0])); if (DEBUG) { System.out.println("ERRORS\n"); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java index 4d866619eb..a07548a83e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,7 +16,6 @@ package org.eclipse.jdt.core.tests.eval; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Vector; import junit.framework.TestCase; @@ -244,13 +243,13 @@ public char[][] localVariableNames() { try { StackFrame frame = getStackFrame(); Iterator variables = frame.visibleVariables().iterator(); - Vector names = new Vector(); + List<char[]> names = new ArrayList<>(); while (variables.hasNext()) { LocalVariable var = (LocalVariable)variables.next(); - names.addElement(var.name().toCharArray()); + names.add(var.name().toCharArray()); } char[][] result = new char[names.size()][]; - names.copyInto(result); + names.toArray(result); return result; } catch (AbsentInformationException e) { return null; @@ -260,13 +259,13 @@ public char[][] localVariableTypeNames() { try { StackFrame frame = getStackFrame(); Iterator variables = frame.visibleVariables().iterator(); - Vector names = new Vector(); + List<char[]> names = new ArrayList(); while (variables.hasNext()) { LocalVariable var = (LocalVariable)variables.next(); - names.addElement(var.typeName().toCharArray()); + names.add(var.typeName().toCharArray()); } char[][] result = new char[names.size()][]; - names.copyInto(result); + names.toArray(result); return result; } catch (AbsentInformationException e) { return null; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java index 8243de27e5..102ee6d844 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -278,7 +278,7 @@ void processClasses(boolean mustRun, byte[][] classDefinitions) { } // load the classes and collect code snippet classes - Vector codeSnippetClasses = new Vector(); + List<Class> codeSnippetClasses = new ArrayList<>(); for (int i = 0; i < newClasses.length; i++) { String className = newClasses[i]; Class clazz = null; @@ -311,7 +311,7 @@ void processClasses(boolean mustRun, byte[][] classDefinitions) { } else if (superclass.equals(this.codeSnippetClass)) { // It may be a code snippet class with no global variable if (methods.length == 1 && methods[0].getName().equals(RUN_METHOD_NAME)) { - codeSnippetClasses.addElement(clazz); + codeSnippetClasses.add(clazz); } // Evaluate global variables and send result back Field[] fields = clazz.getDeclaredFields(); @@ -329,14 +329,14 @@ void processClasses(boolean mustRun, byte[][] classDefinitions) { } } else if (this.codeSnippetClass.equals(superclass.getSuperclass()) && methods.length == 1 && methods[0].getName().equals("run")) { // It is a code snippet class with a global variable superclass - codeSnippetClasses.addElement(clazz); + codeSnippetClasses.add(clazz); } } // run the code snippet classes if (codeSnippetClasses.size() != 0 && mustRun) { - for (Enumeration e = codeSnippetClasses.elements(); e.hasMoreElements();) { - Object codeSnippet = createCodeSnippet((Class) e.nextElement()); + for (Class class1 : codeSnippetClasses) { + Object codeSnippet = createCodeSnippet(class1); if (codeSnippet != null) { runCodeSnippet(codeSnippet); } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java index 14e51e207e..f25cbb7b49 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2014 IBM Corporation and others. + * Copyright (c) 2004, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,13 +15,14 @@ package org.eclipse.jdt.core.tests.junit.extension; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -@SuppressWarnings({ "unchecked", "rawtypes" }) +@SuppressWarnings({ "rawtypes" }) public class PerformanceTestSuite extends TestSuite { /** @@ -43,7 +44,7 @@ public class PerformanceTestSuite extends TestSuite { } Class superClass= theClass; - Vector names= new Vector(); + List<String> names= new ArrayList<>(); while (Test.class.isAssignableFrom(superClass)) { Method[] methods= superClass.getDeclaredMethods(); for (int i= 0; i < methods.length; i++) { @@ -59,7 +60,7 @@ public class PerformanceTestSuite extends TestSuite { setName(name); } - private void addTestMethod(Method m, Vector names, Class theClass) { + private void addTestMethod(Method m, List<String> names, Class theClass) { String name= m.getName(); if (names.contains(name)) return; @@ -68,7 +69,7 @@ public class PerformanceTestSuite extends TestSuite { addTest(addWarningTest("Test method isn't public: "+m.getName())); return; } - names.addElement(name); + names.add(name); addTest(createTest(theClass, name)); } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java index e19bb7add2..4e88b85dfe 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,13 +16,13 @@ package org.eclipse.jdt.core.tests.runtime; import java.io.File; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; /** * This is a new vm launcher to support Apache Harmony * (http://harmony.apache.org) settings */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public class DRLVMLauncher extends StandardVMLauncher { /** @@ -30,7 +30,7 @@ public class DRLVMLauncher extends StandardVMLauncher { */ @Override public String[] getCommandLine() { - Vector commandLine= new Vector(); + List<String> commandLine= new ArrayList<>(); // VM binary String vmLocation = this.vmPath + @@ -42,59 +42,59 @@ public String[] getCommandLine() { if (osName.indexOf("win32") == -1 && !new File(vmLocation).exists()) { vmLocation = vmLocation.substring(0, vmLocation.length()-1); } - commandLine.addElement(vmLocation); + commandLine.add(vmLocation); // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } // boot classpath - commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath()); + commandLine.add("-Xbootclasspath/a:" + buildBootClassPath()); // debug mode if (this.debugPort != -1) { - commandLine.addElement("-Xdebug"); - commandLine.addElement("-Xnoagent"); + commandLine.add("-Xdebug"); + commandLine.add("-Xnoagent"); // commandLine.addElement("-Djava.compiler=NONE"); - commandLine.addElement( + commandLine.add( "-Xrunjdwp:transport=dt_socket,address=" + this.debugPort + ",server=y,suspend=n"); } // regular classpath - commandLine.addElement("-classpath"); - commandLine.addElement(buildClassPath()); + commandLine.add("-classpath"); + commandLine.add(buildClassPath()); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } @@ -105,7 +105,7 @@ public String[] getCommandLine() { result = new String[] {this.batchFileName}; } else { result = new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); } // check for spaces in result diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java index adadab7808..d8129a3dd8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,7 +15,8 @@ package org.eclipse.jdt.core.tests.runtime; import java.io.File; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import org.eclipse.jdt.core.tests.util.Util; @@ -29,7 +30,6 @@ import org.eclipse.jdt.core.tests.util.Util; * must also be specified. This port is used for the communication between the * Proxy and the VM. */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public class J9VMLauncher extends LocalVMLauncher { int internalDebugPort = -1; String proxyOutFile; @@ -93,10 +93,10 @@ protected Process execCommandLine() throws TargetException { */ @Override public String[] getCommandLine() { - Vector commandLine = new Vector(); + List<String> commandLine = new ArrayList<>(); // VM binary - commandLine.addElement( + commandLine.add( this.vmPath + (this.vmPath.endsWith(File.separator) ? "" : File.separator) + "bin" + @@ -106,53 +106,53 @@ public String[] getCommandLine() { // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } // debug mode if (this.debugPort != -1 && this.internalDebugPort != -1) { - commandLine.addElement("-debug:" + this.internalDebugPort); + commandLine.add("-debug:" + this.internalDebugPort); } // boot class path - commandLine.addElement("-Xbootclasspath:" + buildBootClassPath()); + commandLine.add("-Xbootclasspath:" + buildBootClassPath()); // regular class path - commandLine.addElement("-classpath"); - commandLine.addElement(buildClassPath()); + commandLine.add("-classpath"); + commandLine.add(buildClassPath()); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } String[] result= new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); // check for spaces in result for (int i = 0; i < result.length; i++) { @@ -177,10 +177,10 @@ public int getInternalDebugPort() { * Returns the command line which will be used to launch the Proxy. */ public String[] getProxyCommandLine() { - Vector commandLine = new Vector(); + List<String> commandLine = new ArrayList<>(); // Proxy binary - commandLine.addElement( + commandLine.add( this.vmPath + (this.vmPath.endsWith(File.separator) ? "" : File.separator) + "bin" + @@ -188,14 +188,14 @@ public String[] getProxyCommandLine() { "j9proxy"); // Arguments - commandLine.addElement(getTargetAddress() + ":" + this.internalDebugPort); - commandLine.addElement(Integer.toString(this.debugPort)); + commandLine.add(getTargetAddress() + ":" + this.internalDebugPort); + commandLine.add(Integer.toString(this.debugPort)); if (this.symbolPath != null && this.symbolPath != "") { - commandLine.addElement(this.symbolPath); + commandLine.add(this.symbolPath); } String[] result= new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); return result; } /** @@ -246,9 +246,9 @@ public LocalVirtualMachine launch() throws TargetException { // Transform launched VM into J9 VM Process vmProcess = localVM.process; - this.runningVMs.removeElement(localVM); + this.runningVMs.remove(localVM); J9VirtualMachine vm= new J9VirtualMachine(vmProcess, this.debugPort, this.evalTargetPath, proxyProcess, this.proxyOutFile); - this.runningVMs.addElement(vm); + this.runningVMs.add(vm); return vm; } /* (non-Javadoc) diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java index 45c987b433..03c586958b 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,14 +18,13 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; /** * A standard VM launcher launches an external standard VM with * the given arguments on the same machine. */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public class JRockitVMLauncher extends LocalVMLauncher { String batchFileName; /** @@ -61,11 +60,11 @@ public String getBatchFileName() { */ @Override public String[] getCommandLine() { - Vector commandLine= new Vector(); + List<String> commandLine = new ArrayList<>(); // VM binary if (System.getProperty("java.vm.version").startsWith("1.4.2")) { - commandLine.addElement( + commandLine.add( this.vmPath + (this.vmPath.endsWith(File.separator) ? "" : File.separator) + "bin" + @@ -89,21 +88,21 @@ public String[] getCommandLine() { File.separator + "java"; } - commandLine.addElement(vmLocation); + commandLine.add(vmLocation); } // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } // debug mode if (this.debugPort != -1) { - commandLine.addElement("-Xdebug"); - commandLine.addElement("-Xnoagent"); - commandLine.addElement( + commandLine.add("-Xdebug"); + commandLine.add("-Xnoagent"); + commandLine.add( "-Xrunjdwp:transport=dt_socket,address=" + this.debugPort + ",server=y,suspend=n"); @@ -112,37 +111,37 @@ public String[] getCommandLine() { // set the classpath // we don't set the bootclasspath as for StandardVMLauncher as this breaks the debug mode of JRockit // we would get: [JRockit] ERROR: failed to set up MAPI gc reporting - commandLine.addElement("-classpath"); + commandLine.add("-classpath"); String classpath = buildBootClassPath() + File.pathSeparator + buildClassPath(); System.out.println(classpath); - commandLine.addElement(classpath); + commandLine.add(classpath); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } @@ -153,7 +152,7 @@ public String[] getCommandLine() { result = new String[] {this.batchFileName}; } else { result = new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); } // check for spaces in result @@ -175,13 +174,13 @@ public String[] getCommandLine() { public void setBatchFileName(String batchFileName) { this.batchFileName = batchFileName; } -protected void writeBatchFile(String fileName, Vector commandLine) { +protected void writeBatchFile(String fileName, List<String> commandLine) { FileOutputStream output = null; try { output = new FileOutputStream(fileName); PrintWriter out= new PrintWriter(output); - for (Enumeration e = commandLine.elements(); e.hasMoreElements();) { - out.print((String)e.nextElement()); + for (String string : commandLine) { + out.print(string); out.print(" "); } out.println("pause"); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java index 647f93cda1..048dbc3754 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -31,7 +31,6 @@ import org.eclipse.jdt.core.tests.util.Util; * instances will be able to retrieve only a part of the running VMs. * </ul> */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public abstract class LocalVMLauncher implements RuntimeConstants { static final String[] env = System.getenv().entrySet().stream() @@ -55,7 +54,7 @@ public abstract class LocalVMLauncher implements RuntimeConstants { protected String evalTargetPath; protected String[] programArguments; protected String programClass; - protected Vector runningVMs = new Vector(); // a Vector of LocalVirtualMachine + protected List<LocalVirtualMachine> runningVMs = new ArrayList<>(); // a Vector of LocalVirtualMachine protected String[] vmArguments; protected String vmPath; @@ -226,12 +225,10 @@ public String getProgramClass() { */ public LocalVirtualMachine[] getRunningVirtualMachines() { // Select the VMs that are actually running - Vector actuallyRunning = new Vector(); - Enumeration en = this.runningVMs.elements(); - while (en.hasMoreElements()) { - LocalVirtualMachine vm = (LocalVirtualMachine)en.nextElement(); + List<LocalVirtualMachine> actuallyRunning = new ArrayList<>(); + for (LocalVirtualMachine vm : this.runningVMs) { if (vm.isRunning()) - actuallyRunning.addElement(vm); + actuallyRunning.add(vm); } this.runningVMs = actuallyRunning; @@ -239,7 +236,7 @@ public LocalVirtualMachine[] getRunningVirtualMachines() { int size = actuallyRunning.size(); LocalVirtualMachine[] result = new LocalVirtualMachine[size]; for (int i=0; i<size; i++) - result[i] = (LocalVirtualMachine)actuallyRunning.elementAt(i); + result[i] = actuallyRunning.get(i); return result; } /** @@ -408,7 +405,7 @@ public LocalVirtualMachine launch() throws TargetException { // from happening. // add VM to list of known running VMs - this.runningVMs.addElement(vm); + this.runningVMs.add(vm); return vm; } /** diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java index 34ae7f09c6..af6e8f9120 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,21 +14,21 @@ package org.eclipse.jdt.core.tests.runtime; import java.io.File; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; /** * This is a new vm launcher to support sidecar settings */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public class MacVMLauncher extends StandardVMLauncher { /** * @see LocalVMLauncher#getCommandLine */ @Override public String[] getCommandLine() { - Vector commandLine= new Vector(); + List<String> commandLine = new ArrayList<>(); // VM binary - commandLine.addElement( + commandLine.add( this.vmPath + (this.vmPath.endsWith(File.separator) ? "" : File.separator) + "bin" + @@ -38,56 +38,56 @@ public String[] getCommandLine() { // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } // boot classpath - commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath()); + commandLine.add("-Xbootclasspath/a:" + buildBootClassPath()); // debug mode if (this.debugPort != -1) { - commandLine.addElement("-Xdebug"); - commandLine.addElement("-Xnoagent"); - // commandLine.addElement("-Djava.compiler=NONE"); - commandLine.addElement( + commandLine.add("-Xdebug"); + commandLine.add("-Xnoagent"); + // commandLine.add("-Djava.compiler=NONE"); + commandLine.add( "-Xrunjdwp:transport=dt_socket,address=" + this.debugPort + ",server=y,suspend=n"); } else { - commandLine.addElement("-Xdebug"); + commandLine.add("-Xdebug"); } // regular classpath - commandLine.addElement("-classpath"); - commandLine.addElement(buildClassPath()); + commandLine.add("-classpath"); + commandLine.add(buildClassPath()); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } @@ -98,7 +98,7 @@ public String[] getCommandLine() { result = new String[] {this.batchFileName}; } else { result = new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); } // check for spaces in result diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java index 7e087673e5..8df922a9c7 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,21 +14,21 @@ package org.eclipse.jdt.core.tests.runtime; import java.io.File; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; /** * This is a new vm launcher to support sidecar settings */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public class SideCarJ9VMLauncher extends StandardVMLauncher { /** * @see LocalVMLauncher#getCommandLine */ @Override public String[] getCommandLine() { - Vector commandLine= new Vector(); + List<String> commandLine = new ArrayList<>(); // VM binary - commandLine.addElement( + commandLine.add( this.vmPath + (this.vmPath.endsWith(File.separator) ? "" : File.separator) + "bin" + @@ -38,57 +38,57 @@ public String[] getCommandLine() { // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } // boot classpath - commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath()); + commandLine.add("-Xbootclasspath/a:" + buildBootClassPath()); // debug mode - commandLine.addElement("-Xdebug"); + commandLine.add("-Xdebug"); if (this.debugPort != -1) { - commandLine.addElement("-Xnoagent"); - // commandLine.addElement("-Djava.compiler=NONE"); - commandLine.addElement( + commandLine.add("-Xnoagent"); + // commandLine.add("-Djava.compiler=NONE"); + commandLine.add( "-Xrunjdwp:transport=dt_socket,address=" + this.debugPort + ",server=y,suspend=n"); } - commandLine.addElement("-Xj9"); - commandLine.addElement("-Xprod"); + commandLine.add("-Xj9"); + commandLine.add("-Xprod"); // regular classpath - commandLine.addElement("-classpath"); - commandLine.addElement(buildClassPath()); + commandLine.add("-classpath"); + commandLine.add(buildClassPath()); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } @@ -99,7 +99,7 @@ public String[] getCommandLine() { result = new String[] {this.batchFileName}; } else { result = new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); } // check for spaces in result diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java index 6c0b8e4181..e7e243f2d8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,21 +14,21 @@ package org.eclipse.jdt.core.tests.runtime; import java.io.File; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; /** * This is a new vm launcher to support sidecar settings */ -@SuppressWarnings({ "unchecked", "rawtypes" }) public class SideCarVMLauncher extends StandardVMLauncher { /** * @see LocalVMLauncher#getCommandLine */ @Override public String[] getCommandLine() { - Vector commandLine= new Vector(); + List<String> commandLine = new ArrayList<>(); // VM binary - commandLine.addElement( + commandLine.add( this.vmPath + (this.vmPath.endsWith(File.separator) ? "" : File.separator) + "bin" + @@ -38,54 +38,54 @@ public String[] getCommandLine() { // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } // boot classpath - commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath()); + commandLine.add("-Xbootclasspath/a:" + buildBootClassPath()); // debug mode if (this.debugPort != -1) { - commandLine.addElement("-Xdebug"); - commandLine.addElement("-Xnoagent"); - // commandLine.addElement("-Djava.compiler=NONE"); - commandLine.addElement( + commandLine.add("-Xdebug"); + commandLine.add("-Xnoagent"); + // commandLine.add("-Djava.compiler=NONE"); + commandLine.add( "-Xrunjdwp:transport=dt_socket,address=" + this.debugPort + ",server=y,suspend=n"); } // regular classpath - commandLine.addElement("-classpath"); - commandLine.addElement(buildClassPath()); + commandLine.add("-classpath"); + commandLine.add(buildClassPath()); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } @@ -96,7 +96,7 @@ public String[] getCommandLine() { result = new String[] {this.batchFileName}; } else { result = new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); } // check for spaces in result diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java index 3e25d3cc41..223c31c0f3 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,8 +18,8 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -28,7 +28,6 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; * A standard VM launcher launches an external standard VM with * the given arguments on the same machine. */ -@SuppressWarnings({ "rawtypes" ,"unchecked" }) public class StandardVMLauncher extends LocalVMLauncher { String batchFileName; private boolean isJrtBasedVM; @@ -93,7 +92,7 @@ public String getBatchFileName() { */ @Override public String[] getCommandLine() { - Vector commandLine= new Vector(); + List<String> commandLine = new ArrayList<>(); // VM binary StringBuffer vmLocation = new StringBuffer(this.vmPath); @@ -102,72 +101,72 @@ public String[] getCommandLine() { .append("bin") .append(File.separator) .append("java"); - commandLine.addElement(String.valueOf(vmLocation)); + commandLine.add(String.valueOf(vmLocation)); // VM arguments if (this.vmArguments != null) { for (int i = 0; i < this.vmArguments.length; i++) { - commandLine.addElement(this.vmArguments[i]); + commandLine.add(this.vmArguments[i]); } } long vmVersion = Util.getMajorMinorVMVersion(); if (vmVersion != -1) { if (vmVersion < ClassFileConstants.JDK13) { // FailOverToOldVerifier deprecated from 13 - commandLine.addElement("-XX:-FailOverToOldVerifier"); + commandLine.add("-XX:-FailOverToOldVerifier"); } if (vmVersion >= ClassFileConstants.JDK1_6) { - commandLine.addElement("-Xverify:all"); + commandLine.add("-Xverify:all"); } if (vmVersion >= ClassFileConstants.JDK1_7) { - commandLine.addElement("-XX:+UnlockExperimentalVMOptions"); + commandLine.add("-XX:+UnlockExperimentalVMOptions"); } } // debug mode if (this.debugPort != -1) { - commandLine.addElement("-Xdebug"); - commandLine.addElement("-Xnoagent"); - // commandLine.addElement("-Djava.compiler=NONE"); - commandLine.addElement( + commandLine.add("-Xdebug"); + commandLine.add("-Xnoagent"); + // commandLine.add("-Djava.compiler=NONE"); + commandLine.add( "-Xrunjdwp:transport=dt_socket,address=" + this.debugPort + ",server=y,suspend=n"); } // boot classpath - commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath()); + commandLine.add("-Xbootclasspath/a:" + buildBootClassPath()); // regular classpath - commandLine.addElement("-classpath"); - commandLine.addElement(buildClassPath()); + commandLine.add("-classpath"); + commandLine.add(buildClassPath()); // code snippet runner class if (this.evalPort != -1) { - commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME); + commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME); } // code snippet runner arguments if (this.evalPort != -1) { - commandLine.addElement(EVALPORT_ARG); - commandLine.addElement(Integer.toString(this.evalPort)); + commandLine.add(EVALPORT_ARG); + commandLine.add(Integer.toString(this.evalPort)); if (TARGET_HAS_FILE_SYSTEM) { - commandLine.addElement(CODESNIPPET_CLASSPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); - commandLine.addElement(CODESNIPPET_BOOTPATH_ARG); - commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_CLASSPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY); + commandLine.add(CODESNIPPET_BOOTPATH_ARG); + commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY); } } // program class if (this.programClass != null) { - commandLine.addElement(this.programClass); + commandLine.add(this.programClass); } // program arguments if (this.programArguments != null) { for (int i=0;i<this.programArguments.length;i++) { - commandLine.addElement(this.programArguments[i]); + commandLine.add(this.programArguments[i]); } } @@ -178,7 +177,7 @@ public String[] getCommandLine() { result = new String[] {this.batchFileName}; } else { result = new String[commandLine.size()]; - commandLine.copyInto(result); + commandLine.toArray(result); } // check for spaces in result @@ -200,13 +199,13 @@ public String[] getCommandLine() { public void setBatchFileName(String batchFileName) { this.batchFileName = batchFileName; } -protected void writeBatchFile(String fileName, Vector commandLine) { +protected void writeBatchFile(String fileName, List<String> commandLine) { FileOutputStream output = null; try { output = new FileOutputStream(fileName); PrintWriter out= new PrintWriter(output); - for (Enumeration e = commandLine.elements(); e.hasMoreElements();) { - out.print((String)e.nextElement()); + for (String string : commandLine) { + out.print(string); out.print(" "); } out.println("pause"); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java index d216ef7316..93a61dd24e 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -20,7 +20,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.Vector; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; @@ -73,7 +72,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I static protected final int SHOW_JAR_FILE = 0x0400; public static class ConstructorDeclarationsCollector implements IRestrictedAccessConstructorRequestor { - Vector results = new Vector(); + List<String> results = new ArrayList<>(); public void acceptConstructor( int modifiers, @@ -136,7 +135,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I buffer.append('*'); } - this.results.addElement(buffer.toString()); + this.results.add(buffer.toString()); } @Override @@ -165,7 +164,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I buffer.append(c); } public static class MethodDeclarationsCollector implements IRestrictedAccessMethodRequestor { - Vector results = new Vector(); + List<String> results = new ArrayList<>(); @Override public void acceptMethod( @@ -225,7 +224,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I if (parameterCount > 1 && i < parameterCount - 1) buffer.append(','); } buffer.append(')'); - this.results.addElement(buffer.toString()); + this.results.add(buffer.toString()); } private char[] getTypeErasure(char[] typeName) { int index; diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java index d4ebf364f5..a6ebba28ac 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -48,30 +48,30 @@ public class CodeCorrectionTestsRequestor implements ICorrectionRequestor { } - private Vector suggestions = new Vector(5); + private List<Suggestion> suggestions = new ArrayList<>(5); public void acceptClass(char[] packageName,char[] className,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){ - this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd)); + this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd)); } public void acceptField(char[] declaringTypePackageName,char[] declaringTypeName,char[] name,char[] typePackageName,char[] typeName,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){ - this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd)); + this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd)); } public void acceptInterface(char[] packageName,char[] interfaceName,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){ - this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd)); + this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd)); } public void acceptLocalVariable(char[] name,char[] typePackageName,char[] typeName,int modifiers,int correctionStart,int correctionEnd){ - this.suggestions.addElement(new Suggestion(name, correctionStart, correctionEnd)); + this.suggestions.add(new Suggestion(name, correctionStart, correctionEnd)); } public void acceptMethod(char[] declaringTypePackageName,char[] declaringTypeName,char[] selector,char[][] parameterPackageNames,char[][] parameterTypeNames,char[][] parameterNames,char[] returnTypePackageName,char[] returnTypeName,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){ - this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd)); + this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd)); } public void acceptPackage(char[] packageName,char[] correctionName,int correctionStart,int correctionEnd){ - this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd)); + this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd)); } public String getSuggestions(){ diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java index 44517d317b..e5f487d4ae 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.model; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import org.eclipse.jdt.core.CompletionProposal; import org.eclipse.jdt.core.CompletionRequestor; @@ -24,28 +25,27 @@ import org.eclipse.jdt.core.Signature; * {@link CompletionTestsRequestor} is deprecated. {@link CompletionTestsRequestor2} must be used instead. */ //TODO all instances of CompletionTestsRequestor should be replaced by an instance of CompletionTestsRequestor2 -@SuppressWarnings({"rawtypes", "unchecked"}) public class CompletionTestsRequestor extends CompletionRequestor { - private Vector elements = new Vector(); - private Vector completions = new Vector(); - private Vector relevances = new Vector(); - private Vector completionStart = new Vector(); - private Vector completionEnd = new Vector(); + private List<String> elements = new ArrayList<>(); + private List<String> completions = new ArrayList<>(); + private List<String> relevances = new ArrayList<>(); + private List<String> completionStart = new ArrayList<>(); + private List<String> completionEnd = new ArrayList<>(); public boolean debug = false; private void acceptCommon(CompletionProposal proposal) { - this.completions.addElement(new String(proposal.getCompletion())); - this.relevances.addElement(String.valueOf(proposal.getRelevance())); - this.completionStart.addElement(String.valueOf(proposal.getReplaceStart())); - this.completionEnd.addElement(String.valueOf(proposal.getReplaceEnd())); + this.completions.add(new String(proposal.getCompletion())); + this.relevances.add(String.valueOf(proposal.getRelevance())); + this.completionStart.add(String.valueOf(proposal.getReplaceStart())); + this.completionEnd.add(String.valueOf(proposal.getReplaceEnd())); } public void accept(CompletionProposal proposal) { char[] typeName = null; switch(proposal.getKind()) { case CompletionProposal.ANONYMOUS_CLASS_DECLARATION : typeName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature()); - this.elements.addElement(new String(typeName)); + this.elements.add(new String(typeName)); acceptCommon(proposal); if (this.debug) System.out.println("anonymous type " + new String(typeName)); @@ -56,13 +56,13 @@ public class CompletionTestsRequestor extends CompletionRequestor { } else if((proposal.getFlags() & Flags.AccInterface) != 0) { typeName = Signature.getSignatureSimpleName(proposal.getSignature()); - this.elements.addElement(new String(typeName)); + this.elements.add(new String(typeName)); acceptCommon(proposal); if (this.debug) System.out.println("Interface " + new String(typeName)); } else { typeName = Signature.getSignatureSimpleName(proposal.getSignature()); - this.elements.addElement(new String(typeName)); + this.elements.add(new String(typeName)); acceptCommon(proposal); if (this.debug) { if(Signature.getTypeSignatureKind(proposal.getSignature()) == Signature.TYPE_VARIABLE_SIGNATURE) { @@ -75,56 +75,56 @@ public class CompletionTestsRequestor extends CompletionRequestor { break; case CompletionProposal.FIELD_REF : - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("Field " + new String(proposal.getName())); break; case CompletionProposal.KEYWORD: - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("Keyword " + new String(proposal.getName())); break; case CompletionProposal.LABEL_REF: - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("Label " + new String(proposal.getName())); break; case CompletionProposal.LOCAL_VARIABLE_REF: - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("Local variable " + new String(proposal.getName())); break; case CompletionProposal.METHOD_REF: - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("method " + new String(proposal.getName())); break; case CompletionProposal.METHOD_DECLARATION: - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("method declaration " + new String(proposal.getName())); break; case CompletionProposal.PACKAGE_REF: - this.elements.addElement(new String(proposal.getDeclarationSignature())); + this.elements.add(new String(proposal.getDeclarationSignature())); acceptCommon(proposal); if (this.debug) System.out.println("package " + new String(proposal.getDeclarationSignature())); break; case CompletionProposal.VARIABLE_DECLARATION: - this.elements.addElement(new String(proposal.getName())); + this.elements.add(new String(proposal.getName())); acceptCommon(proposal); if (this.debug) System.out.println("variable name " + new String(proposal.getName())); @@ -168,19 +168,19 @@ public class CompletionTestsRequestor extends CompletionRequestor { StringBuffer buffer = new StringBuffer(); buffer.append("element:"); - buffer.append(this.elements.elementAt(i)); + buffer.append(this.elements.get(i)); buffer.append(" completion:"); - buffer.append(this.completions.elementAt(i)); + buffer.append(this.completions.get(i)); if(position) { buffer.append(" position:["); - buffer.append(this.completionStart.elementAt(i)); + buffer.append(this.completionStart.get(i)); buffer.append(","); - buffer.append(this.completionEnd.elementAt(i)); + buffer.append(this.completionEnd.get(i)); buffer.append("]"); } if(relevance) { buffer.append(" relevance:"); - buffer.append(this.relevances.elementAt(i)); + buffer.append(this.relevances.get(i)); } return buffer.toString(); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java index 10d903c525..75b489cded 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7014,7 +7014,7 @@ public void testBug127628() throws CoreException { CharOperation.concatWith(enclosingTypeNames, '$'), simpleTypeName, '$'); - this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.'))); + this.results.add(new String(CharOperation.concat(packageName, typeName, '.'))); } } } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java index c1ab8b45ce..b730d1c537 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,7 +15,8 @@ package org.eclipse.jdt.core.tests.model; import java.io.FileInputStream; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -38,7 +39,6 @@ import junit.framework.Test; /* * Test indexing support. */ -@SuppressWarnings({"rawtypes", "unchecked"}) public class SearchTests extends ModifyingResourceTests implements IJavaSearchConstants { /* * Empty jar contents. @@ -78,7 +78,7 @@ public class SearchTests extends ModifyingResourceTests implements IJavaSearchCo } } public static class SearchMethodNameRequestor extends MethodNameRequestor { - Vector results = new Vector<>(); + List<String> results = new ArrayList<>(); @Override public void acceptMethod( char[] methodName, @@ -136,7 +136,7 @@ public class SearchTests extends ModifyingResourceTests implements IJavaSearchCo if (parameterCount > 1 && i < parameterCount - 1) buffer.append(','); } buffer.append(')'); - this.results.addElement(buffer.toString()); + this.results.add(buffer.toString()); } static void checkAndAddtoBuffer(StringBuffer buffer, char[] precond, char c) { if (precond == null || precond.length == 0) return; @@ -162,14 +162,14 @@ public class SearchTests extends ModifyingResourceTests implements IJavaSearchCo } } public static class SearchTypeNameRequestor extends TypeNameRequestor { - Vector results = new Vector(); + List<String> results = new ArrayList<>(); public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { char[] typeName = CharOperation.concat( CharOperation.concatWith(enclosingTypeNames, '$'), simpleTypeName, '$'); - this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.'))); + this.results.add(new String(CharOperation.concat(packageName, typeName, '.'))); } public String toString(){ int length = this.results.size(); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java index 919f84655c..b28e9a2b82 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,7 +14,8 @@ package org.eclipse.jdt.core.tests.model; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import junit.framework.Test; @@ -27,8 +28,6 @@ import org.eclipse.jdt.internal.core.util.Util; import org.eclipse.team.core.RepositoryProvider; - -@SuppressWarnings({"rawtypes", "unchecked"}) public class WorkingCopyTests extends ModifyingResourceTests { ICompilationUnit cu = null; ICompilationUnit copy = null; @@ -462,14 +461,14 @@ public void testGetPrimaryInnerType() { assertTrue("Element is not a method", primary instanceof IType); assertTrue("Element should exist", primary.exists()); - Vector hierarchy = new Vector(5); + List<IJavaElement> hierarchy = new ArrayList<>(5); IJavaElement parent= primary.getParent(); while (parent.getElementType() > IJavaElement.COMPILATION_UNIT) { - hierarchy.addElement(parent); + hierarchy.add(parent); parent = parent.getParent(); } - hierarchy.addElement(parent); - assertTrue("Compilation Unit should not be a working copy", !((ICompilationUnit)hierarchy.lastElement()).isWorkingCopy()); + hierarchy.add(parent); + assertTrue("Compilation Unit should not be a working copy", !((ICompilationUnit)hierarchy.get(hierarchy.size() - 1)).isWorkingCopy()); } /** * Ensures that the primary method can be retrieved. diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java index ddfe2f8342..fc44454369 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2017 IBM Corporation and others. + * Copyright (c) 2006, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,8 +14,8 @@ package org.eclipse.jdt.core.dom; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.compiler.CharOperation; @@ -28,7 +28,7 @@ import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToIntArray; /** * Internal AST visitor for propagating syntax errors. */ -@SuppressWarnings({"rawtypes", "unchecked"}) +@SuppressWarnings({"rawtypes"}) class ASTRecoveryPropagator extends DefaultASTVisitor { private static final int NOTHING = -1; HashtableOfObjectToIntArray endingTokens = new HashtableOfObjectToIntArray(); @@ -92,7 +92,7 @@ class ASTRecoveryPropagator extends DefaultASTVisitor { private boolean[] removedTokensFlagged; private boolean[] replacedTokensFlagged; - private Vector stack = new Vector(); + private ArrayList<ASTNode> stack = new ArrayList<>(); ASTRecoveryPropagator(CategorizedProblem[] problems, RecoveryScannerData data) { // visit Javadoc.tags() as well @@ -252,12 +252,12 @@ class ASTRecoveryPropagator extends DefaultASTVisitor { if(this.insertedTokensKind != null && this.insertedTokensKind.length > 0) { int s = this.stack.size(); for (int i = s - 1; i > -1; i--) { - flagNodesWithInsertedTokensAtEnd((ASTNode)this.stack.get(i)); + flagNodesWithInsertedTokensAtEnd(this.stack.get(i)); } for (int i = 0; i < s; i++) { - flagNodesWithInsertedTokensInside((ASTNode)this.stack.get(i)); + flagNodesWithInsertedTokensInside(this.stack.get(i)); } - this.stack = new Vector(); + this.stack = new ArrayList<>(); } } |