changeset 2:63a685efe415

some problems on windows fixed, contributed by: alexey.fedorchenko@oracle.com
author bkurotsu
date Fri, 25 Apr 2014 12:37:38 -0600
parents f928322a5e0b
children 22d15cf94d61
files src/classes/com/sun/tdk/jcov/GrabberManager.java src/classes/com/sun/tdk/jcov/report/javap/JavapClassReader.java src/classes/com/sun/tdk/jcov/report/javap/JavapRepGen.java src/classes/com/sun/tdk/jcov/runtime/JCovXMLFileSaver.java
diffstat 4 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/classes/com/sun/tdk/jcov/GrabberManager.java	Mon Mar 31 17:01:10 2014 +0400
+++ b/src/classes/com/sun/tdk/jcov/GrabberManager.java	Fri Apr 25 12:37:38 2014 -0600
@@ -102,7 +102,7 @@
         } catch (UnknownHostException e) {
             throw new Exception("Can't resolve hostname '" + host + "'");
         } catch (IOException e) {
-            if ("Connection refused".equals(e.getMessage())) {
+            if (e.getMessage() != null && e.getMessage().startsWith("Connection refused")) {
                 throw new Exception("Server not responding on command port " + port);
             } else {
                 throw e;
--- a/src/classes/com/sun/tdk/jcov/report/javap/JavapClassReader.java	Mon Mar 31 17:01:10 2014 +0400
+++ b/src/classes/com/sun/tdk/jcov/report/javap/JavapClassReader.java	Fri Apr 25 12:37:38 2014 -0600
@@ -68,6 +68,20 @@
                             Class classToLoad = Class.forName("com.sun.tools.javap.Main", true, classLoader);
                             method = classToLoad.getDeclaredMethod("run", String[].class, PrintWriter.class);
                             instance = classToLoad.newInstance();
+
+                            String[] params = null;
+
+                            if (jarPath == null) {
+                                params = new String[]{"-c", "-p", filePath};
+                            } else {
+                                params = new String[]{"-c", "-p", "-classpath", jarPath, filePath};
+                            }
+                            try {
+                                Object result = method.invoke(instance, params, pw);
+                            } catch (Exception ex) {
+                                printToolsJarError();
+                            }
+
                         } catch (Exception e) {
                             printToolsJarError();
                         }
--- a/src/classes/com/sun/tdk/jcov/report/javap/JavapRepGen.java	Mon Mar 31 17:01:10 2014 +0400
+++ b/src/classes/com/sun/tdk/jcov/report/javap/JavapRepGen.java	Fri Apr 25 12:37:38 2014 -0600
@@ -220,7 +220,13 @@
 
             for (File classFile : files) {
 
-                String className = classFile.getAbsolutePath().replaceFirst(classesPath + "/", "").replace(".class", "");
+                String className = classFile.getAbsolutePath();
+                if (classFile.getAbsolutePath().startsWith(classesPath + File.separator)){
+                    className = className.substring(classesPath.length()+1);
+                }
+                if (className.endsWith(".class")) {
+                    className = className.substring(0, className.lastIndexOf(".class"));
+                }
 
                 if (Utils.accept(Utils.concatFilters(include, exclude), null, "/" + className, null)) {
                     newFiles.add(classFile);
--- a/src/classes/com/sun/tdk/jcov/runtime/JCovXMLFileSaver.java	Mon Mar 31 17:01:10 2014 +0400
+++ b/src/classes/com/sun/tdk/jcov/runtime/JCovXMLFileSaver.java	Fri Apr 25 12:37:38 2014 -0600
@@ -73,6 +73,7 @@
                     root.xmlGen(ctx);
                     ctx.close();
 
+                    channel.truncate(0);
                     channel.write(ByteBuffer.wrap(os.toByteArray()));
                     lock.release();
                     channel.close();