Bug 507668 - Move org.eclipse.build.tools to Java 8
Jump to Java 1.8, enabling more warnings and fixing them.
Change-Id: Iaf4bada97b0e628f4fa15352b50e9acd4c32069b
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.build.tools/.classpath b/bundles/org.eclipse.build.tools/.classpath
index 64c5e31..eca7bdb 100644
--- a/bundles/org.eclipse.build.tools/.classpath
+++ b/bundles/org.eclipse.build.tools/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.core.prefs
index b7c4384..19724d2 100644
--- a/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.core.prefs
@@ -21,13 +21,16 @@
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -41,27 +44,27 @@
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@@ -69,20 +72,22 @@
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
@@ -92,18 +97,19 @@
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
@@ -116,7 +122,7 @@
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
diff --git a/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.launching.prefs b/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.launching.prefs
index b2e4c49..d211d32 100644
--- a/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.launching.prefs
+++ b/bundles/org.eclipse.build.tools/.settings/org.eclipse.jdt.launching.prefs
@@ -1,2 +1,2 @@
eclipse.preferences.version=1
-org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=error
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
diff --git a/bundles/org.eclipse.build.tools/META-INF/MANIFEST.MF b/bundles/org.eclipse.build.tools/META-INF/MANIFEST.MF
index bb7ab45..1abc8af 100644
--- a/bundles/org.eclipse.build.tools/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.build.tools/META-INF/MANIFEST.MF
@@ -2,10 +2,10 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.build.tools; singleton:=true
-Bundle-Version: 1.0.1.qualifier
+Bundle-Version: 1.1.0.qualifier
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.apache.ant,
org.eclipse.osgi
Bundle-ClassPath: buildTools.jar
diff --git a/bundles/org.eclipse.build.tools/pom.xml b/bundles/org.eclipse.build.tools/pom.xml
index 3f99dac..1e5da04 100644
--- a/bundles/org.eclipse.build.tools/pom.xml
+++ b/bundles/org.eclipse.build.tools/pom.xml
@@ -12,6 +12,6 @@
</parent>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.build.tools</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/ElementParser.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/ElementParser.java
index b3c344f..003620c 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/ElementParser.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/ElementParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. 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
@@ -60,9 +60,9 @@
}
private SAXParser parser;
- private final Vector plugins;
+ private final Vector<String> plugins;
- private final Vector features;
+ private final Vector<String> features;
public ElementParser() {
// Create a Xerces SAX Parser
@@ -80,21 +80,21 @@
// instantiate vectors that will hold lists of plugins and features read
// from feature.xml
- plugins = new Vector();
- features = new Vector();
+ plugins = new Vector<>();
+ features = new Vector<>();
}
- public void add(final String element, final Vector v) {
+ public void add(final String element, final Vector<String> v) {
if (!v.contains(element)) {
v.add(element);
}
}
- public Vector getFeatures() {
+ public Vector<String> getFeatures() {
return features;
}
- public Vector getPlugins() {
+ public Vector<String> getPlugins() {
return plugins;
}
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/FetchValidator.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/FetchValidator.java
index 0dcd13d..a45cfdd 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/FetchValidator.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/FetchValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. 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
@@ -40,21 +40,21 @@
// Comma separated list of features to parse
private String list;
// Elements to check for post fetch (use name of project in dev.eclipse.org)
- private Vector features;
+ private Vector<String> features;
- private Vector plugins;
+ private Vector<String> plugins;
// keeps track of missing elements
- private final Vector missingPlugins;
+ private final Vector<String> missingPlugins;
- private final Vector missingFeatures;
+ private final Vector<String> missingFeatures;
// parser
ElementParser parser;
public FetchValidator() {
parser = new ElementParser();
- missingPlugins = new Vector();
- missingFeatures = new Vector();
+ missingPlugins = new Vector<>();
+ missingFeatures = new Vector<>();
}
private boolean allPresent() {
@@ -62,10 +62,10 @@
// collect a list of missing plugins (or fragments), and features
boolean allPresent = true;
- Enumeration enumeration = plugins.elements();
+ Enumeration<String> enumeration = plugins.elements();
while (enumeration.hasMoreElements()) {
- final String plugin = (String) enumeration.nextElement();
+ final String plugin = enumeration.nextElement();
if (new File(install + "/plugins/" + plugin).exists()) {
continue;
} else {
@@ -77,7 +77,7 @@
enumeration = features.elements();
while (enumeration.hasMoreElements()) {
- final String feature = (String) enumeration.nextElement();
+ final String feature = enumeration.nextElement();
if (new File(install + "/features/" + feature).exists()) {
continue;
} else {
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/UnpackUpdateJars.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/UnpackUpdateJars.java
index 2a0b730..80e27df 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/UnpackUpdateJars.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/UnpackUpdateJars.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2005, 2016 IBM Corporation and others. 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
@@ -75,7 +75,7 @@
private String output;
- ArrayList unpackedPlugins = new ArrayList();
+ ArrayList<String> unpackedPlugins = new ArrayList<>();
public UnpackUpdateJars() {
super();
@@ -107,8 +107,8 @@
// unpack plug-ins
for (int i = 0; i < unpackedPlugins.size(); i++) {
- final File unpackedPluginDirName = new File(output + "/plugins/" + (String) unpackedPlugins.get(i));
- final File jardPlugin = new File(site, "plugins/" + (String) unpackedPlugins.get(i) + ".jar");
+ final File unpackedPluginDirName = new File(output + "/plugins/" + unpackedPlugins.get(i));
+ final File jardPlugin = new File(site, "plugins/" + unpackedPlugins.get(i) + ".jar");
if (jardPlugin.exists()) {
unzip(jardPlugin, unpackedPluginDirName);
}
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/ErrorTracker.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/ErrorTracker.java
index 652dab0..8480e46 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/ErrorTracker.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/ErrorTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. 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
@@ -53,22 +53,22 @@
}
- private Set<String> testLogsSet = Collections.checkedSortedSet(new TreeSet(),String.class);
+ private Set<String> testLogsSet = Collections.checkedSortedSet(new TreeSet<>(),String.class);
// Platforms keyed on
- private final Hashtable platforms = new Hashtable();
- private final Hashtable logFiles = new Hashtable();
- private final Hashtable typesMap = new Hashtable();
+ private final Hashtable<String, PlatformStatus> platforms = new Hashtable<>();
+ private final Hashtable<String, Vector<PlatformStatus>> logFiles = new Hashtable<>();
+ private final Hashtable<String, Vector<String>> typesMap = new Hashtable<>();
- private final Vector typesList = new Vector();
+ private final Vector<String> typesList = new Vector<>();
private String convertPathDelimiters(final String path) {
return new File(path).getPath();
}
public PlatformStatus[] getPlatforms(final String type) {
- final Vector platformIDs = (Vector) typesMap.get(type);
+ final Vector<String> platformIDs = typesMap.get(type);
final PlatformStatus[] result = new PlatformStatus[platformIDs.size()];
for (int i = 0; i < platformIDs.size(); i++) {
- result[i] = (PlatformStatus) platforms.get(platformIDs.elementAt(i));
+ result[i] = platforms.get(platformIDs.elementAt(i));
}
return result;
}
@@ -81,7 +81,7 @@
public List<String> getTestLogs(ArrayList<String> foundConfigs) {
// List of test logs expected at end of build
// We depend on both test logs and configs being sorted
- ArrayList<String> testLogs = new ArrayList();
+ ArrayList<String> testLogs = new ArrayList<>();
for (String initialLogName : testLogsSet) {
for (String config : foundConfigs) {
testLogs.add(initialLogName + "_" + config + ".xml");
@@ -93,13 +93,13 @@
// Answer a string array of the zip type names in the order they appear in
// the .xml file.
public String[] getTypes() {
- return (String[]) typesList.toArray(new String[typesList.size()]);
+ return typesList.toArray(new String[typesList.size()]);
}
// Answer an array of PlatformStatus objects for a given type.
public boolean hasErrors(final String id) {
- return ((PlatformStatus) platforms.get(id)).hasErrors();
+ return platforms.get(id).hasErrors();
}
public void loadFile(final String fileName) {
@@ -124,10 +124,10 @@
final Node zipType = elements.item(i).getParentNode();
final String zipTypeName = zipType.getAttributes().getNamedItem("name").getNodeValue();
- Vector aVector = (Vector) typesMap.get(zipTypeName);
+ Vector<String> aVector = typesMap.get(zipTypeName);
if (aVector == null) {
typesList.add(zipTypeName);
- aVector = new Vector();
+ aVector = new Vector<>();
typesMap.put(zipTypeName, aVector);
}
aVector.add(aPlatform.getId());
@@ -143,13 +143,13 @@
logFileName = convertPathDelimiters(logFileName);
final String effectedFileID = anEffectedFile.getAttributes().getNamedItem("id").getNodeValue();
// System.out.println(logFileName);
- Vector aVector = (Vector) logFiles.get(logFileName);
+ Vector<PlatformStatus> aVector = logFiles.get(logFileName);
if (aVector == null) {
- aVector = new Vector();
+ aVector = new Vector<>();
logFiles.put(logFileName, aVector);
}
- final PlatformStatus ps = (PlatformStatus) platforms.get(effectedFileID);
+ final PlatformStatus ps = platforms.get(effectedFileID);
if (ps != null) {
aVector.addElement(ps);
}
@@ -204,18 +204,18 @@
public void registerError(final String fileName) {
// System.out.println("Found an error in: " + fileName);
if (logFiles.containsKey(fileName)) {
- final Vector aVector = (Vector) logFiles.get(fileName);
+ final Vector<PlatformStatus> aVector = logFiles.get(fileName);
for (int i = 0; i < aVector.size(); i++) {
- ((PlatformStatus) aVector.elementAt(i)).registerError();
+ aVector.elementAt(i).registerError();
}
} else {
// If a log file is not specified explicitly it effects
// all "platforms" except JDT
- final Enumeration values = platforms.elements();
+ final Enumeration<PlatformStatus> values = platforms.elements();
while (values.hasMoreElements()) {
- final PlatformStatus aValue = (PlatformStatus) values.nextElement();
+ final PlatformStatus aValue = values.nextElement();
if (!aValue.getId().equals("JA") && !aValue.getId().equals("EW") && !aValue.getId().equals("EA")) {
aValue.registerError();
}
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/PlatformStatus.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/PlatformStatus.java
index 8a55f61..512b7cd 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/PlatformStatus.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/PlatformStatus.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. 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
@@ -19,11 +19,10 @@
public class PlatformStatus {
- private static List listFromString(final String value) {
- final List result = new ArrayList();
+ private static List<String> listFromString(final String value) {
+ final List<String> result = new ArrayList<>();
for (final StringTokenizer tokenizer = new StringTokenizer(value, ","); tokenizer.hasMoreTokens(); result.add(tokenizer
.nextToken())) {
- ;
}
return result;
}
@@ -32,7 +31,7 @@
private final String name;
private final String fileName;
private String format;
- private List images;
+ private List<String> images;
private boolean hasErrors = false;
@@ -65,7 +64,7 @@
return id;
}
- public List getImages() {
+ public List<String> getImages() {
return images;
}
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/TestResultsGenerator.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/TestResultsGenerator.java
index 39151c9..ed0627f 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/TestResultsGenerator.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/TestResultsGenerator.java
@@ -58,8 +58,8 @@
public class ResultsTable implements Iterable<String> {
- private Map<String, Row> rows = new TreeMap();
- private List<String> columns = new ArrayList();
+ private Map<String, Row> rows = new TreeMap<>();
+ private List<String> columns = new ArrayList<>();
public ResultsTable(ArrayList<String> columns) {
super();
@@ -88,7 +88,7 @@
private class Row {
- Map<String, Cell> row = new TreeMap();
+ Map<String, Cell> row = new TreeMap<>();
public Row(List<String> columns) {
super();
@@ -150,6 +150,7 @@
this.columns = columns;
}
+ @Override
public Iterator<String> iterator() {
return rows.keySet().iterator();
}
@@ -175,7 +176,7 @@
private String expected_config_type = "expected";
private String expectedConfigFilename;
private String foundConfigFilename;
- private Vector dropTokens;
+ private Vector<String> dropTokens;
private String testResultsWithProblems = EOL;
private String testResultsXmlUrls = EOL;
@@ -230,7 +231,7 @@
// solution found)
private boolean doMissingList = true;
- private Set<String> missingManifestFiles = Collections.checkedSortedSet(new TreeSet(), String.class);
+ private Set<String> missingManifestFiles = Collections.checkedSortedSet(new TreeSet<>(), String.class);
class ExpectedConfigFiler implements FilenameFilter {
@@ -240,6 +241,7 @@
configEnding = expectedConfigEnding;
}
+ @Override
public boolean accept(File dir, String name) {
return (name.endsWith(configEnding));
}
@@ -272,22 +274,10 @@
}
private static byte[] getFileByteContent(final String fileName) throws IOException {
- InputStream stream = null;
- try {
- final File file = new File(fileName);
- stream = new BufferedInputStream(new FileInputStream(file));
+ final File file = new File(fileName);
+ try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) {
return getInputStreamAsByteArray(stream, (int) file.length());
}
- finally {
- if (stream != null) {
- try {
- stream.close();
- }
- catch (final IOException e) {
- // ignore
- }
- }
- }
}
/**
@@ -668,13 +658,13 @@
/**
* @return
*/
- public Vector getDropTokens() {
+ public Vector<String> getDropTokens() {
return dropTokens;
}
private void getDropTokensFromList(final String list) {
final StringTokenizer tokenizer = new StringTokenizer(list, ",");
- dropTokens = new Vector();
+ dropTokens = new Vector<>();
while (tokenizer.hasMoreTokens()) {
dropTokens.add(tokenizer.nextToken());
@@ -746,9 +736,7 @@
final File file = new File(log);
Document aDocument = null;
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(file));
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))){
final InputSource inputSource = new InputSource(reader);
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
@@ -763,16 +751,6 @@
catch (final ParserConfigurationException e) {
logException(e);
}
- finally {
- if (reader != null) {
- try {
- reader.close();
- }
- catch (final IOException e) {
- // ignore
- }
- }
- }
if (aDocument == null) {
return;
@@ -878,7 +856,7 @@
private void parseJUnitTestsXml() throws IOException {
log("DEBUG: Begin: Parsing XML JUnit results files");
- ArrayList<String> foundConfigs = new ArrayList();
+ ArrayList<String> foundConfigs = new ArrayList<>();
final File xmlResultsDirectory = new File(getXmlDirectoryName());
ResultsTable resultsTable = new ResultsTable(getTestsConfig());
if (xmlResultsDirectory.exists()) {
@@ -889,7 +867,7 @@
// tests completed).
foundConfigs.clear();
- ArrayList<File> allFileNames = new ArrayList();
+ ArrayList<File> allFileNames = new ArrayList<>();
for (String expectedConfig : getTestsConfig()) {
@@ -1100,27 +1078,28 @@
private void writePhpConfigFile(String config_type, ArrayList<String> configs, String phpfilename) throws IOException {
File mainDir = new File(getDropDirectoryName());
File testConfigsFile = new File(mainDir, phpfilename);
- Writer testconfigsPHP = new FileWriter(testConfigsFile);
- testconfigsPHP.write("<?php" + EOL);
- testconfigsPHP.write("//This file created by 'generateIndex' ant task, while parsing test results" + EOL);
- testconfigsPHP.write("// It is based on " + config_type + " testConfigs" + EOL);
- String phpArrayVariableName = "$" + config_type + "TestConfigs";
- testconfigsPHP.write(phpArrayVariableName + " = array();" + EOL);
- for (String fConfig : configs) {
- testconfigsPHP.write(phpArrayVariableName + "[]=\"" + fConfig + "\";" + EOL);
+ try (Writer testconfigsPHP = new FileWriter(testConfigsFile)) {
+ testconfigsPHP.write("<?php" + EOL);
+ testconfigsPHP.write("//This file created by 'generateIndex' ant task, while parsing test results" + EOL);
+ testconfigsPHP.write("// It is based on " + config_type + " testConfigs" + EOL);
+ String phpArrayVariableName = "$" + config_type + "TestConfigs";
+ testconfigsPHP.write(phpArrayVariableName + " = array();" + EOL);
+ for (String fConfig : configs) {
+ testconfigsPHP.write(phpArrayVariableName + "[]=\"" + fConfig + "\";" + EOL);
+ }
}
- testconfigsPHP.close();
}
private void writePhpIncludeCompilerResultsFile(final File sourceDirectory, String compilerSummary) throws IOException {
File mainDir = new File(getDropDirectoryName());
File compilerSummaryFile = new File(mainDir, compilerSummaryFilename);
- Writer compilerSummaryPHP = new FileWriter(compilerSummaryFile);
- compilerSummaryPHP.write("<!--" + EOL);
- compilerSummaryPHP.write(" This file created by 'generateIndex' ant task, while parsing build and tests results" + EOL);
- compilerSummaryPHP.write("-->" + EOL);
- compilerSummaryPHP.write(compilerSummary);
- compilerSummaryPHP.close();
+ try (Writer compilerSummaryPHP = new FileWriter(compilerSummaryFile)) {
+ compilerSummaryPHP.write("<!--" + EOL);
+ compilerSummaryPHP
+ .write(" This file created by 'generateIndex' ant task, while parsing build and tests results" + EOL);
+ compilerSummaryPHP.write("-->" + EOL);
+ compilerSummaryPHP.write(compilerSummary);
+ }
}
private void processCompileLogsDirectory(final String directoryName, final StringBuffer compilerLog,
@@ -1178,9 +1157,9 @@
final String filename = aPlatform.getFileName();
// if there are images, put them in the same table column as the name of
// the file
- final List images = aPlatform.getImages();
+ final List<String> images = aPlatform.getImages();
if ((images != null) && !images.isEmpty()) {
- for (final Iterator iter = images.iterator(); iter.hasNext();) {
+ for (final Iterator<String> iter = images.iterator(); iter.hasNext();) {
result = result + "<img src=\"" + iter.next() + "\"/> ";
}
}
@@ -1285,7 +1264,7 @@
/**
* @param vector
*/
- public void setDropTokens(final Vector vector) {
+ public void setDropTokens(final Vector<String> vector) {
dropTokens = vector;
}
@@ -1344,7 +1323,7 @@
private String verifyAllTestsRan(final String directory, ArrayList<String> foundConfigs) {
String replaceString = "";
- ArrayList<String> missingFiles = new ArrayList();
+ ArrayList<String> missingFiles = new ArrayList<>();
if (getDoMissingList()) {
for (String testLogName : anErrorTracker.getTestLogs(foundConfigs)) {
@@ -1412,9 +1391,7 @@
}
private void writeFile(File outputFile, final String contents) {
- OutputStream outputStream = null;
- try {
- outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
+ try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile))){
outputStream.write(contents.getBytes());
}
catch (final FileNotFoundException e) {
@@ -1423,16 +1400,6 @@
catch (final IOException e) {
log(EOL + "ERROR: IOException writing: " + outputFile.getPath());
}
- finally {
- if (outputStream != null) {
- try {
- outputStream.close();
- }
- catch (final IOException e) {
- // ignore
- }
- }
- }
}
/*
@@ -1461,7 +1428,7 @@
private ArrayList<String> getTestsConfig() throws IOException {
if (expectedConfigs == null) {
- expectedConfigs = new ArrayList<String>();
+ expectedConfigs = new ArrayList<>();
String expectedConfigParam = getTestsConfigExpected();
if (expectedConfigParam != null) {
StringTokenizer tokenizer = new StringTokenizer(expectedConfigParam, " ,\t");
@@ -1534,9 +1501,9 @@
}
results = results + EOL + "</table>";
xmlFragment = xmlFragment + "</topLevel>";
- FileWriter xmlOutput = new FileWriter(getDropDirectoryName() + "/addToTestManifest.xml");
+ try (FileWriter xmlOutput = new FileWriter(getDropDirectoryName() + "/addToTestManifest.xml")) {
xmlOutput.write(xmlFragment);
- xmlOutput.close();
+ }
}
}
return results;
diff --git a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/VersionTrackerTask.java b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/VersionTrackerTask.java
index 0b3859d..cc55992 100644
--- a/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/VersionTrackerTask.java
+++ b/bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/VersionTrackerTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. 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
@@ -86,11 +86,11 @@
private String buildDirectory;
- private Hashtable elements;
+ private Hashtable<String, String> elements;
private SAXParser parser;
- private Vector allElements;
+ private Vector<String> allElements;
// the feature to from which to collect version information
private String featurePath;
@@ -102,8 +102,8 @@
}
public VersionTrackerTask(final String install) {
- elements = new Hashtable();
- allElements = new Vector();
+ elements = new Hashtable<>();
+ allElements = new Vector<>();
final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
try {
@@ -192,19 +192,14 @@
}
public void writeProperties(final String propertiesFile, final boolean append) {
- try {
-
- final PrintWriter writer = new PrintWriter(new FileWriter(propertiesFile, append));
-
- final Enumeration keys = elements.keys();
+ try (final PrintWriter writer = new PrintWriter(new FileWriter(propertiesFile, append))){
+ final Enumeration<String> keys = elements.keys();
while (keys.hasMoreElements()) {
- final Object key = keys.nextElement();
- writer.println(key.toString() + "=" + elements.get(key).toString());
+ final String key = keys.nextElement();
+ writer.println(key + "=" + elements.get(key).toString());
writer.flush();
}
- writer.close();
-
}
catch (final IOException e) {
System.out.println("Unable to write to file " + propertiesFile);