Bug 528712 - Move launcher BREE to 1.7

Silence resource warnings and handle zipfile with try-with-resources to
ensure it's closed.

Change-Id: Ic2d0601029fc03770920b52a28c0c2fa055a037d
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
index dff5953..72c0845 100644
--- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
+++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
@@ -647,6 +647,7 @@
 				parent = appCL.getParent();
 		} else if (PARENT_CLASSLOADER_CURRENT.equalsIgnoreCase(type))
 			parent = this.getClass().getClassLoader();
+		@SuppressWarnings("resource")
 		URLClassLoader loader = new StartupClassLoader(bootPath, parent);
 		Class<?> clazz = loader.loadClass(STARTER);
 		Method method = clazz.getDeclaredMethod("run", String[].class, Runnable.class); //$NON-NLS-1$
@@ -2377,39 +2378,43 @@
 			if (!clean)
 				return splash.getAbsolutePath();
 		}
-		ZipFile file;
-		try {
-			file = new ZipFile(jarPath);
+
+		try (ZipFile file = new ZipFile(jarPath)) {
+			ZipEntry entry = file.getEntry(jarEntry.replace(File.separatorChar, '/'));
+			if (entry == null)
+				return null;
+			InputStream input = null;
+			try {
+				input = file.getInputStream(entry);
+			} catch (IOException e) {
+				log("Exception opening splash: " + entry.getName() + " in JAR file: " + jarPath); //$NON-NLS-1$ //$NON-NLS-2$
+				log(e);
+				return null;
+			}
+			new File(splash.getParent()).mkdirs();
+			OutputStream output;
+			try {
+				output = new BufferedOutputStream(new FileOutputStream(splash));
+			} catch (FileNotFoundException e) {
+				try {
+					input.close();
+				} catch (IOException e1) {
+					// ignore
+				}
+				return null;
+			}
+			transferStreams(input, output);
+			try {
+				file.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			return splash.exists() ? splash.getAbsolutePath() : null;
 		} catch (IOException e) {
 			log("Exception looking for " + jarEntry + " in JAR file: " + jarPath); //$NON-NLS-1$ //$NON-NLS-2$
 			log(e);
 			return null;
 		}
-		ZipEntry entry = file.getEntry(jarEntry.replace(File.separatorChar, '/'));
-		if (entry == null)
-			return null;
-		InputStream input = null;
-		try {
-			input = file.getInputStream(entry);
-		} catch (IOException e) {
-			log("Exception opening splash: " + entry.getName() + " in JAR file: " + jarPath); //$NON-NLS-1$ //$NON-NLS-2$
-			log(e);
-			return null;
-		}
-		new File(splash.getParent()).mkdirs();
-		OutputStream output;
-		try {
-			output = new BufferedOutputStream(new FileOutputStream(splash));
-		} catch (FileNotFoundException e) {
-			try {
-				input.close();
-			} catch (IOException e1) {
-				// ignore
-			}
-			return null;
-		}
-		transferStreams(input, output);
-		return splash.exists() ? splash.getAbsolutePath() : null;
 	}
 
 	/*