[jboss-cvs] JBoss Profiler SVN: r437 - branches/JBossProfiler2/src/main/org/jboss/profiler/agent.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun May 11 09:06:02 EDT 2008
Author: jesper.pedersen
Date: 2008-05-11 09:06:01 -0400 (Sun, 11 May 2008)
New Revision: 437
Modified:
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java
Log:
Check instrumentation library during startup
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java 2008-05-11 12:31:34 UTC (rev 436)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java 2008-05-11 13:06:01 UTC (rev 437)
@@ -790,16 +790,21 @@
if (clz != null) {
for (Class c : clz) {
- byte[] buffer = null;
- if (instrument) {
- buffer = transformer.loadInstrumented(c.getName(), c.getClassLoader());
- } else {
- buffer = transformer.loadNonInstrumented(c.getName(), c.getClassLoader());
- }
+ try {
+ byte[] buffer = null;
+ if (instrument) {
+ buffer = transformer.loadInstrumented(c.getName(), c.getClassLoader());
+ } else {
+ buffer = transformer.loadNonInstrumented(c.getName(), c.getClassLoader());
+ }
- if (buffer != null) {
- ClassDefinition cd = new ClassDefinition(c, buffer);
- l.add(cd);
+ if (buffer != null) {
+ ClassDefinition cd = new ClassDefinition(c, buffer);
+ l.add(cd);
+ }
+ } catch (Throwable it) {
+ System.err.println(it.getMessage());
+ it.printStackTrace(System.err);
}
}
}
@@ -816,6 +821,28 @@
}
}
+ /**
+ * Check for the presence of the instrumentation library
+ * @return True if detection went ok; otherwise false
+ */
+ private static boolean checkInstrumentation() {
+ if (useJavassist) {
+ try {
+ Class c = Class.forName("javassist.ClassPool");
+ } catch (Throwable t) {
+ System.out.println("WARNING: Javassist not detected - the profiler will not be enabled");
+ return false;
+ }
+ } else {
+ try {
+ Class c = Class.forName("org.objectweb.asm.ClassAdapter");
+ } catch (Throwable t) {
+ System.out.println("WARNING: ASM not detected - the profiler will not be enabled");
+ return false;
+ }
+ }
+ return true;
+ }
/**
* The agentmain method
@@ -875,6 +902,7 @@
System.out.println("JBoss Profiler not enabled");
}
+ checkInstrumentation();
if (useJavassist) {
transformer = new JavassistTransformer();
} else {
More information about the jboss-cvs-commits
mailing list