incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r988370 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/util/RunJar.java
Date Tue, 24 Aug 2010 01:44:25 GMT
Author: edwardyoon
Date: Tue Aug 24 01:44:24 2010
New Revision: 988370

URL: http://svn.apache.org/viewvc?rev=988370&view=rev
Log:
Fix generics warnings 

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/util/RunJar.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=988370&r1=988369&r2=988370&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Tue Aug 24 01:44:24 2010
@@ -150,6 +150,7 @@ Trunk (unreleased changes)
 
   BUG FIXES
   
+    HAMA-280: Fix warnings (Filipe Manana via edwardyoon)
     HAMA-270: wrong sequence of readFields() of ClusterStatus (hyunsik)
     HAMA-260: Current version command of script is linked unknown class (edwardyoon)
     HAMA-250: Add --no-check-certificate option to 'wget' command lines (edwardyoon)

Modified: incubator/hama/trunk/src/java/org/apache/hama/util/RunJar.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/util/RunJar.java?rev=988370&r1=988369&r2=988370&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/util/RunJar.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/util/RunJar.java Tue Aug 24 01:44:24 2010
@@ -13,6 +13,7 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -25,9 +26,9 @@ public class RunJar {
   public static void unJar(File jarFile, File toDir) throws IOException {
     JarFile jar = new JarFile(jarFile);
     try {
-      Enumeration entries = jar.entries();
+      Enumeration<JarEntry> entries = jar.entries();
       while (entries.hasMoreElements()) {
-        JarEntry entry = (JarEntry)entries.nextElement();
+        JarEntry entry = (JarEntry) entries.nextElement();
         if (!entry.isDirectory()) {
           InputStream in = jar.getInputStream(entry);
           try {
@@ -53,8 +54,10 @@ public class RunJar {
     }
   }
 
-  /** Run a Hadoop job jar.  If the main class is not in the jar's manifest,
-   * then it must be provided on the command line. */
+  /**
+   * Run a Hadoop job jar. If the main class is not in the jar's manifest, then
+   * it must be provided on the command line.
+   */
   public static void main(String[] args) throws Throwable {
     String usage = "RunJar jarFile [mainClass] args...";
 
@@ -84,46 +87,45 @@ public class RunJar {
     }
     mainClassName = mainClassName.replaceAll("/", ".");
 
-    final File workDir = File.createTempFile("hama-unjar","");
+    final File workDir = File.createTempFile("hama-unjar", "");
     workDir.delete();
     workDir.mkdirs();
 
     Runtime.getRuntime().addShutdownHook(new Thread() {
-        public void run() {
-          try {
-            FileUtil.fullyDelete(workDir);
-          } catch (IOException e) {
-          }
+      public void run() {
+        try {
+          FileUtil.fullyDelete(workDir);
+        } catch (IOException e) {
         }
-      });
+      }
+    });
 
     unJar(file, workDir);
-    
-    ArrayList classPath = new ArrayList();
-    classPath.add(new File(workDir+"/").toURL());
-    classPath.add(file.toURL());
-    classPath.add(new File(workDir, "classes/").toURL());
+
+    List<URL> classPath = new ArrayList<URL>();
+    classPath.add(new File(workDir + "/").toURI().toURL());
+    classPath.add(file.toURI().toURL());
+    classPath.add(new File(workDir, "classes/").toURI().toURL());
     File[] libs = new File(workDir, "lib").listFiles();
     if (libs != null) {
       for (int i = 0; i < libs.length; i++) {
-        classPath.add(libs[i].toURL());
+        classPath.add(libs[i].toURI().toURL());
       }
     }
-    ClassLoader loader =
-      new URLClassLoader((URL[])classPath.toArray(new URL[0]));
+    ClassLoader loader = new URLClassLoader((URL[]) classPath
+        .toArray(new URL[0]));
 
     Thread.currentThread().setContextClassLoader(loader);
-    Class mainClass = loader.loadClass(mainClassName);
-    Method main = mainClass.getMethod("main", new Class[] {
-      Array.newInstance(String.class, 0).getClass()
-    });
-    String[] newArgs = (String[])Arrays.asList(args)
-      .subList(firstArg, args.length).toArray(new String[0]);
+    Class<?> mainClass = loader.loadClass(mainClassName);
+    Method main = mainClass.getMethod("main", new Class[] { Array.newInstance(
+        String.class, 0).getClass() });
+    String[] newArgs = (String[]) Arrays.asList(args).subList(firstArg,
+        args.length).toArray(new String[0]);
     try {
       main.invoke(null, new Object[] { newArgs });
     } catch (InvocationTargetException e) {
       throw e.getTargetException();
     }
   }
-  
+
 }



Mime
View raw message