Author: erwan
Date: Thu Jan 12 09:01:06 2012
New Revision: 1230444
URL: http://svn.apache.org/viewvc?rev=1230444&view=rev
Log:
OFBIZ-3651 - Minor tweaks to the Cobertura integration - A patch from Bob
Morley. I've also changed the cobertura version from 1.9.3 to 1.9.4.1 (latest)
as your modifications are allowing it
Modified:
ofbiz/trunk/build.xml
ofbiz/trunk/framework/base/src/org/ofbiz/base/config/CoberturaInstrumenter.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java
ofbiz/trunk/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java
ofbiz/trunk/ivy.xml
Modified: ofbiz/trunk/build.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/build.xml?rev=1230444&r1=1230443&r2=1230444&view=diff
==============================================================================
--- ofbiz/trunk/build.xml (original)
+++ ofbiz/trunk/build.xml Thu Jan 12 09:01:06 2012
@@ -936,7 +936,7 @@ under the License.
<taskdef resource="tasks.properties">
<classpath>
<fileset dir="framework/base/lib">
- <include name="cobertura-1.9.3.jar" />
+ <include name="cobertura-1.9.4.1.jar" />
<include name="log4j-1.2.15.jar" />
<include name="scripting/asm*.jar" />
</fileset>
@@ -964,7 +964,7 @@ under the License.
<taskdef resource="tasks.properties">
<classpath>
<fileset dir="framework/base/lib">
- <include name="cobertura-1.9.3.jar" />
+ <include name="cobertura-1.9.4.1.jar" />
<include name="log4j-1.2.15.jar" />
<include name="scripting/asm*.jar" />
</fileset>
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/config/CoberturaInstrumenter.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/CoberturaInstrumenter.java?rev=1230444&r1=1230443&r2=1230444&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/config/CoberturaInstrumenter.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/config/CoberturaInstrumenter.java
Thu Jan 12 09:01:06 2012
@@ -25,17 +25,16 @@ import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.ClassVisitor;
-
import net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler;
import net.sourceforge.cobertura.coveragedata.ProjectData;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
import org.ofbiz.base.start.Instrumenter;
public final class CoberturaInstrumenter implements Instrumenter {
- private static final Constructor INSTRUMENTER_CONSTRUCTOR;
+ private static final Constructor<?> INSTRUMENTER_CONSTRUCTOR;
private static final Method IS_INSTRUMENTED_METHOD;
static {
try {
@@ -77,14 +76,18 @@ public final class CoberturaInstrumenter
}
public byte[] instrumentClass(byte[] bytes) throws IOException {
- ClassReader cr = new ClassReader(bytes);
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS/* |
ClassWriter.COMPUTE_FRAMES*/);
- try {
- ClassVisitor ci = (ClassVisitor)
INSTRUMENTER_CONSTRUCTOR.newInstance(projectData != null ? projectData :
ProjectData.getGlobalProjectData(), cw, Collections.EMPTY_LIST,
Collections.EMPTY_LIST);
- cr.accept(ci, 0);
- if (((Boolean) IS_INSTRUMENTED_METHOD.invoke(ci)).booleanValue())
return cw.toByteArray();
- } catch (Throwable t) {
- throw (IOException) new IOException(t.getMessage()).initCause(t);
+ if (forInstrumenting) {
+ ClassReader cr = new ClassReader(bytes);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS/* |
ClassWriter.COMPUTE_FRAMES*/);
+ try {
+ ClassVisitor ci = (ClassVisitor)
INSTRUMENTER_CONSTRUCTOR.newInstance(projectData, cw, Collections.EMPTY_LIST,
Collections.EMPTY_LIST);
+ cr.accept(ci, 0);
+ if (((Boolean)
IS_INSTRUMENTED_METHOD.invoke(ci)).booleanValue()) {
+ return cw.toByteArray();
+ }
+ } catch (Throwable t) {
+ throw (IOException) new
IOException(t.getMessage()).initCause(t);
+ }
}
return bytes;
}
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java?rev=1230444&r1=1230443&r2=1230444&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java
Thu Jan 12 09:01:06 2012
@@ -136,7 +136,10 @@ public class ComponentContainer implemen
// set the new classloader/classpath on the current thread
if (updateClasspath) {
- classPath.instrument(instrumenterFile, instrumenterClassName);
+ if (UtilValidate.isNotEmpty(instrumenterFile) &&
UtilValidate.isNotEmpty(instrumenterClassName)) {
+ classPath.instrument(instrumenterFile, instrumenterClassName);
+ }
+
System.setProperty("java.class.path", classPath.toString());
System.setProperty("java.library.path", libraryPath.toString());
ClassLoader cl = classPath.getClassLoader();
Modified:
ofbiz/trunk/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java?rev=1230444&r1=1230443&r2=1230444&view=diff
==============================================================================
---
ofbiz/trunk/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java
(original)
+++
ofbiz/trunk/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java
Thu Jan 12 09:01:06 2012
@@ -71,7 +71,7 @@ public final class InstrumenterWorker {
e.printStackTrace();
return srcPaths;
} catch (ClassNotFoundException e) {
- e.printStackTrace();
+ System.err.println("InstrumenterWorker.instrument - Code
instrumentation has been disabled, unable to find instrumenter class " +
instrumenterClassName);
return srcPaths;
}
ScheduledThreadPoolExecutor executor = new
ScheduledThreadPoolExecutor(ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors());
Modified: ofbiz/trunk/ivy.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/ivy.xml?rev=1230444&r1=1230443&r2=1230444&view=diff
==============================================================================
--- ofbiz/trunk/ivy.xml (original)
+++ ofbiz/trunk/ivy.xml Thu Jan 12 09:01:06 2012
@@ -25,12 +25,12 @@
<description homepage="http://ofbiz.apache.org/"/>
</info>
<configurations>
- <conf name="cobertura" description="downloads cobertura 1.9.3 (GPL2.0)
http://cobertura.sourceforge.net/"/>
+ <conf name="cobertura" description="downloads cobertura 1.9.4.1
(GPL2.0) http://cobertura.sourceforge.net/"/>
<conf name="postgres" description="downloads the postgres JDBC
driver"/>
<conf name="sonar-ant-task" description="downloads the ant sonar task
(need sonar>=2.6)"/>
</configurations>
<dependencies>
- <dependency org="net.sourceforge.cobertura" name="cobertura"
rev="1.9.3" conf="cobertura->default"/>
+ <dependency org="net.sourceforge.cobertura" name="cobertura"
rev="1.9.4.1" conf="cobertura->default"/>
<dependency org="postgresql" name="postgresql" rev="9.0-801.jdbc4"
conf="postgres->default"/>
<dependency org="org.codehaus.sonar-plugins" name="sonar-ant-task"
rev="1.0" conf="sonar-ant-task->default"/>