(char[],int,int)
+
+ /**
+ * Constructs an XMLString structure with copies of the values in
+ * the given structure.
+ *
+ * Note: This does not copy the character array;
+ * only the reference to the array is copied.
+ *
+ * @param string The XMLString to copy.
+ */
+ public XMLString(XMLString string) {
+ setValues(string);
+ } // (XMLString)
+
+ //
+ // Public methods
+ //
+
+ /**
+ * Initializes the contents of the XMLString structure with the
+ * specified values.
+ *
+ * @param ch The character array.
+ * @param offset The offset into the character array.
+ * @param length The length of characters from the offset.
+ */
+ public void setValues(char[] ch, int offset, int length) {
+ this.ch = ch;
+ this.offset = offset;
+ this.length = length;
+ } // setValues(char[],int,int)
+
+ public void setValues(XMLString s) {
+ setValues(s.ch, s.offset, s.length);
+ } // setValues(XMLString)
+
+ public void clear() {
+ this.ch = null;
+ this.offset = 0;
+ this.length = -1;
+ } // clear()
+
+ /**
+ * Returns true if the contents of this XMLString structure and
+ * the specified array are equal.
+ *
+ * @param ch The character array.
+ * @param offset The offset into the character array.
+ * @param length The length of characters from the offset.
+ */
+ public boolean equals(char[] ch, int offset, int length) {
+ if (ch == null) {
+ return false;
+ }
+ if (this.length != length) {
+ return false;
+ }
+
+ for (int i=0; i 0 ? new String(ch, offset, length) : "";
+ } // toString():String
+
+}
+
+class XMLStringBuffer
+ extends XMLString {
+
+ //
+ // Constants
+ //
+
+
+ /** Default buffer size (32). */
+ public static final int DEFAULT_SIZE = 32;
+
+ //
+ // Data
+ //
+
+ //
+ // Constructors
+ //
+
+ /**
+ *
+ */
+ public XMLStringBuffer() {
+ this(DEFAULT_SIZE);
+ } // ()
+
+ /**
+ *
+ *
+ * @param size
+ */
+ public XMLStringBuffer(int size) {
+ ch = new char[size];
+ } // (int)
+
+ /** Constructs a string buffer from a char. */
+ public XMLStringBuffer(char c) {
+ this(1);
+ append(c);
+ } // (char)
+
+ /** Constructs a string buffer from a String. */
+ public XMLStringBuffer(String s) {
+ this(s.length());
+ append(s);
+ } // (String)
+
+ /** Constructs a string buffer from the specified character array. */
+ public XMLStringBuffer(char[] ch, int offset, int length) {
+ this(length);
+ append(ch, offset, length);
+ } // (char[],int,int)
+
+ /** Constructs a string buffer from the specified XMLString. */
+ public XMLStringBuffer(XMLString s) {
+ this(s.length);
+ append(s);
+ } // (XMLString)
+
+ //
+ // Public methods
+ //
+
+ /** Clears the string buffer. */
+ public void clear() {
+ offset = 0;
+ length = 0;
+ }
+
+ /**
+ * append
+ *
+ * @param c
+ */
+ public void append(char c) {
+ if(this.length + 1 > this.ch.length){
+ int newLength = this.ch.length * 2 ;
+ if(newLength < this.ch.length + DEFAULT_SIZE){
+ newLength = this.ch.length + DEFAULT_SIZE;
+ }
+ char [] tmp = new char[newLength];
+ System.arraycopy(this.ch, 0, tmp, 0, this.length);
+ this.ch = tmp;
+ }
+ this.ch[this.length] = c ;
+ this.length++;
+ } // append(char)
+
+ /**
+ * append
+ *
+ * @param s
+ */
+ public void append(String s) {
+ int length = s.length();
+ if (this.length + length > this.ch.length) {
+ int newLength = this.ch.length * 2 ;
+ if(newLength < this.ch.length + length + DEFAULT_SIZE){
+ newLength = this.ch.length + length+ DEFAULT_SIZE;
+ }
+
+ char[] newch = new char[newLength];
+ System.arraycopy(this.ch, 0, newch, 0, this.length);
+ this.ch = newch;
+ }
+ s.getChars(0, length, this.ch, this.length);
+ this.length += length;
+ } // append(String)
+
+ /**
+ * append
+ *
+ * @param ch
+ * @param offset
+ * @param length
+ */
+ public void append(char[] ch, int offset, int length) {
+ if (this.length + length > this.ch.length) {
+ int newLength = this.ch.length * 2 ;
+ if(newLength < this.ch.length + length + DEFAULT_SIZE){
+ newLength = this.ch.length + length + DEFAULT_SIZE;
+ }
+ char[] newch = new char[newLength];
+ System.arraycopy(this.ch, 0, newch, 0, this.length);
+ this.ch = newch;
+ }
+ //making the code more robust as it would handle null or 0 length data,
+ //add the data only when it contains some thing
+ if(ch != null && length > 0){
+ System.arraycopy(ch, offset, this.ch, this.length, length);
+ this.length += length;
+ }
+ } // append(char[],int,int)
+
+ /**
+ * append
+ *
+ * @param s
+ */
+ public void append(XMLString s) {
+ append(s.ch, s.offset, s.length);
+ } // append(XMLString)
+
+
+} // class XMLStringBuffer
diff --git a/jsonde.profiler/src/main/java/com/jsonde/profiler/Profiler.java b/jsonde.profiler/src/main/java/com/jsonde/profiler/Profiler.java
index acc327f..5e79d0f 100755
--- a/jsonde.profiler/src/main/java/com/jsonde/profiler/Profiler.java
+++ b/jsonde.profiler/src/main/java/com/jsonde/profiler/Profiler.java
@@ -42,6 +42,10 @@ public static void enterMethod(long methodId) {
getProfiler().enterMethodImpl(methodId);
}
+ public static void preEnterConstructor(long methodId) {
+ getProfiler().preEnterConstructorImpl(methodId);
+ }
+
public static final String ENTER_CONSTRUCTOR_METHOD_NAME =
"enterConstructor";
public static final String ENTER_CONSTRUCTOR_METHOD_DESCRIPTOR =
@@ -120,6 +124,7 @@ public static void enterConstructor(long methodId, Object that) {
protected void describeClassImpl(long methodId, Class clazz) {};
public void enterMethodImpl(long methodId) {};
+ public void preEnterConstructorImpl(long methodId) {};
protected void enterConstructorImpl(long methodId, Object that) {};
diff --git a/jsonde.profiler/src/main/java/com/jsonde/profiler/ProfilerImpl.java b/jsonde.profiler/src/main/java/com/jsonde/profiler/ProfilerImpl.java
index 4f8ffd9..7ea8441 100755
--- a/jsonde.profiler/src/main/java/com/jsonde/profiler/ProfilerImpl.java
+++ b/jsonde.profiler/src/main/java/com/jsonde/profiler/ProfilerImpl.java
@@ -374,8 +374,8 @@ public void redefineClass(
redefineClassesExecutor.execute(new Runnable() {
public void run() {
+ Class clazz = null;
try {
- Class clazz;
if (null == classLoader) {
clazz = ClassLoader.getSystemClassLoader().loadClass(className);
@@ -391,6 +391,9 @@ public void run() {
instrumentation.redefineClasses(new ClassDefinition[]{classDefinition});
+ } catch (VerifyError e) {
+ System.err.println("Error while transforming class " + className + " loaded by " + classLoader + " ; class is " + clazz);
+ e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (UnmodifiableClassException e) {