diff options
author | Sarika Sinha | 2015-03-03 11:30:46 +0000 |
---|---|---|
committer | Sarika Sinha | 2015-03-03 11:30:46 +0000 |
commit | 25611f0b960f8297cf41ec2a2ffe7d49c22209aa (patch) | |
tree | 87156c58215bd21bb8a456eb5ea0f607c6bebc10 /org.eclipse.debug.core | |
parent | 9e0b67e5552fec7597bc1da9d9bc705816275409 (diff) | |
download | eclipse.platform.debug-25611f0b960f8297cf41ec2a2ffe7d49c22209aa.tar.gz eclipse.platform.debug-25611f0b960f8297cf41ec2a2ffe7d49c22209aa.tar.xz eclipse.platform.debug-25611f0b960f8297cf41ec2a2ffe7d49c22209aa.zip |
Bug 461219 - Compile warnings in official buildI20150303-0800
Change-Id: I48f14fe5c9ee51a09ede0bc30380cb8e55b5ada2
Diffstat (limited to 'org.eclipse.debug.core')
3 files changed, 70 insertions, 71 deletions
diff --git a/org.eclipse.debug.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.debug.core/.settings/org.eclipse.jdt.core.prefs index cb08f9df6..854ba028d 100644 --- a/org.eclipse.debug.core/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.debug.core/.settings/org.eclipse.jdt.core.prefs @@ -35,7 +35,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod= org.eclipse.jdt.core.compiler.problem.discouragedReference=warning 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=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=error org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index 0d77b6204..7ecf979fe 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -797,75 +797,79 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe //read piped data on Win 95, 98, and ME Properties p= new Properties(); File file= new File(fileName); - InputStream stream = new BufferedInputStream(new FileInputStream(file)); - p.load(stream); - stream.close(); - if (!file.delete()) { - file.deleteOnExit(); // if delete() fails try again on VM close - } - for (Entry<Object, Object> entry : p.entrySet()) { - // Win32's environment variables are case insensitive. Put everything - // to uppercase so that (for example) the "PATH" variable will match - // "pAtH" correctly on Windows. - String key = (String) entry.getKey(); - //no need to cast value - cache.put(key, (String) p.get(key)); + try(InputStream stream = new BufferedInputStream(new FileInputStream(file))){ + p.load(stream); + if (!file.delete()) { + file.deleteOnExit(); // if delete() fails try again on VM close + } + for (Entry<Object, Object> entry : p.entrySet()) { + // Win32's environment variables are case insensitive. Put everything + // to uppercase so that (for example) the "PATH" variable will match + // "pAtH" correctly on Windows. + String key = (String) entry.getKey(); + //no need to cast value + cache.put(key, (String) p.get(key)); + } } } else { //read process directly on other platforms //we need to parse out matching '{' and '}' for function declarations in .bash environments // pattern is [func name]=() { and we must find the '}' on its own line with no trailing ';' - InputStream stream = process.getInputStream(); + try (InputStream stream = process.getInputStream(); InputStreamReader isreader = new InputStreamReader(stream); - BufferedReader reader = new BufferedReader(isreader); - String line = reader.readLine(); - String key = null; - String value = null; - String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ - while (line != null) { - int func = line.indexOf("=()"); //$NON-NLS-1$ - if(func > 0) { - key = line.substring(0, func); - //scan until we find the closing '}' with no following chars - value = line.substring(func+1); - while(line != null && !line.equals("}")) { //$NON-NLS-1$ - line = reader.readLine(); - if(line != null) { - value += newLine + line; + BufferedReader reader = new BufferedReader(isreader)) { + String line = reader.readLine(); + String key = null; + String value = null; + String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ + while (line != null) { + int func = line.indexOf("=()"); //$NON-NLS-1$ + if (func > 0) { + key = line.substring(0, func); + // scan until we find the closing '}' with no + // following chars + value = line.substring(func + 1); + while (line != null && !line.equals("}")) { //$NON-NLS-1$ + line = reader.readLine(); + if (line != null) { + value += newLine + line; + } } - } - line = reader.readLine(); - } - else { - int separator = line.indexOf('='); - if (separator > 0) { - key = line.substring(0, separator); - value = line.substring(separator + 1); line = reader.readLine(); - if(line != null) { - // this line has a '=' read ahead to check next line for '=', might be broken on more than one line - // also if line starts with non-identifier - it is remainder of previous variable - while (line.indexOf('=') < 0 || (line.length()>0 && !Character.isJavaIdentifierStart(line.charAt(0)))) { - value += newLine + line; - line = reader.readLine(); - if(line == null) { - //if next line read is the end of the file quit the loop - break; + } + else { + int separator = line.indexOf('='); + if (separator > 0) { + key = line.substring(0, separator); + value = line.substring(separator + 1); + line = reader.readLine(); + if (line != null) { + // this line has a '=' read ahead to check + // next line for '=', might be broken on + // more than one line + // also if line starts with non-identifier - + // it is remainder of previous variable + while (line.indexOf('=') < 0 || (line.length() > 0 && !Character.isJavaIdentifierStart(line.charAt(0)))) { + value += newLine + line; + line = reader.readLine(); + if (line == null) { + // if next line read is the end of + // the file quit the loop + break; + } } } } } - } - if(key != null) { - cache.put(key, value); - key = null; - value = null; - } - else { - line = reader.readLine(); + if (key != null) { + cache.put(key, value); + key = null; + value = null; + } else { + line = reader.readLine(); + } } } - reader.close(); } } catch (IOException e) { // Native environment-fetching code failed. @@ -2632,15 +2636,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe * @since 3.4.0 */ private void copyFile(File in, File out) throws IOException { - FileInputStream fis = new FileInputStream(in); - FileOutputStream fos = new FileOutputStream(out); - byte[] buf = new byte[1024]; - int i = 0; - while((i = fis.read(buf)) != -1) { - fos.write(buf, 0, i); + try (FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out)) { + byte[] buf = new byte[1024]; + int i = 0; + while ((i = fis.read(buf)) != -1) { + fos.write(buf, 0, i); + } } - fis.close(); - fos.close(); } /** diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java index 9b98e0b20..5e29625a2 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2015 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 @@ -447,12 +447,9 @@ public final class XMLMemento { * @throws IOException if there is a problem serializing the document to the stream. */ public void save(Writer writer) throws IOException { - DOMWriter out = new DOMWriter(writer); - try { + try (DOMWriter out = new DOMWriter(writer)) { out.print(element); - } finally { - out.close(); - } + } } /** |