Skip to content

Commit ccebbf7

Browse files
committed
Latest patches from ASM trunk
(cherry picked from commit cfc720d)
1 parent c350080 commit ccebbf7

File tree

4 files changed

+67
-63
lines changed

4 files changed

+67
-63
lines changed

spring-core/src/main/java/org/springframework/asm/Item.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,12 @@ void set(final int type, final String strVal1, final String strVal2,
208208
this.strVal2 = strVal2;
209209
this.strVal3 = strVal3;
210210
switch (type) {
211+
case ClassWriter.CLASS:
212+
this.intVal = 0; // intVal of a class must be zero, see visitInnerClass
213+
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());
214+
return;
211215
case ClassWriter.UTF8:
212216
case ClassWriter.STR:
213-
case ClassWriter.CLASS:
214217
case ClassWriter.MTYPE:
215218
case ClassWriter.TYPE_NORMAL:
216219
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());

spring-core/src/main/java/org/springframework/asm/Label.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ boolean inSameSubroutine(final Label block) {
473473
void addToSubroutine(final long id, final int nbSubroutines) {
474474
if ((status & VISITED) == 0) {
475475
status |= VISITED;
476-
srcAndRefPositions = new int[(nbSubroutines - 1) / 32 + 1];
476+
srcAndRefPositions = new int[nbSubroutines / 32 + 1];
477477
}
478478
srcAndRefPositions[(int) (id >>> 32)] |= (int) id;
479479
}

spring-core/src/main/java/org/springframework/asm/MethodWriter.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,43 +1966,43 @@ private void writeFrameTypes(final int start, final int end) {
19661966
stackMap.putByte(v);
19671967
}
19681968
} else {
1969-
StringBuffer buf = new StringBuffer();
1969+
StringBuilder sb = new StringBuilder();
19701970
d >>= 28;
19711971
while (d-- > 0) {
1972-
buf.append('[');
1972+
sb.append('[');
19731973
}
19741974
if ((t & Frame.BASE_KIND) == Frame.OBJECT) {
1975-
buf.append('L');
1976-
buf.append(cw.typeTable[t & Frame.BASE_VALUE].strVal1);
1977-
buf.append(';');
1975+
sb.append('L');
1976+
sb.append(cw.typeTable[t & Frame.BASE_VALUE].strVal1);
1977+
sb.append(';');
19781978
} else {
19791979
switch (t & 0xF) {
19801980
case 1:
1981-
buf.append('I');
1981+
sb.append('I');
19821982
break;
19831983
case 2:
1984-
buf.append('F');
1984+
sb.append('F');
19851985
break;
19861986
case 3:
1987-
buf.append('D');
1987+
sb.append('D');
19881988
break;
19891989
case 9:
1990-
buf.append('Z');
1990+
sb.append('Z');
19911991
break;
19921992
case 10:
1993-
buf.append('B');
1993+
sb.append('B');
19941994
break;
19951995
case 11:
1996-
buf.append('C');
1996+
sb.append('C');
19971997
break;
19981998
case 12:
1999-
buf.append('S');
1999+
sb.append('S');
20002000
break;
20012001
default:
2002-
buf.append('J');
2002+
sb.append('J');
20032003
}
20042004
}
2005-
stackMap.putByte(7).putShort(cw.newClass(buf.toString()));
2005+
stackMap.putByte(7).putShort(cw.newClass(sb.toString()));
20062006
}
20072007
}
20082008
}

spring-core/src/main/java/org/springframework/asm/Type.java

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ public static Type getReturnType(final Method method) {
401401
* @return the size of the arguments of the method (plus one for the
402402
* implicit this argument), argSize, and the size of its return
403403
* value, retSize, packed into a single int i =
404-
* <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal to
405-
* <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
404+
* <tt>(argSize &lt;&lt; 2) | retSize</tt> (argSize is therefore equal to
405+
* <tt>i &gt;&gt; 2</tt>, and retSize to <tt>i &amp; 0x03</tt>).
406406
*/
407407
public static int getArgumentsAndReturnSizes(final String desc) {
408408
int n = 1;
@@ -556,11 +556,11 @@ public String getClassName() {
556556
case DOUBLE:
557557
return "double";
558558
case ARRAY:
559-
StringBuffer b = new StringBuffer(getElementType().getClassName());
559+
StringBuilder sb = new StringBuilder(getElementType().getClassName());
560560
for (int i = getDimensions(); i > 0; --i) {
561-
b.append("[]");
561+
sb.append("[]");
562562
}
563-
return b.toString();
563+
return sb.toString();
564564
case OBJECT:
565565
return new String(buf, off, len).replace('/', '.');
566566
default:
@@ -606,9 +606,10 @@ public Type getReturnType() {
606606
*
607607
* @return the size of the arguments (plus one for the implicit this
608608
* argument), argSize, and the size of the return value, retSize,
609-
* packed into a single int i = <tt>(argSize << 2) | retSize</tt>
610-
* (argSize is therefore equal to <tt>i >> 2</tt>, and retSize to
611-
* <tt>i & 0x03</tt>).
609+
* packed into a single
610+
* int i = <tt>(argSize &lt;&lt; 2) | retSize</tt>
611+
* (argSize is therefore equal to <tt>i &gt;&gt; 2</tt>,
612+
* and retSize to <tt>i &amp; 0x03</tt>).
612613
*/
613614
public int getArgumentsAndReturnSizes() {
614615
return getArgumentsAndReturnSizes(getDescriptor());
@@ -624,9 +625,9 @@ public int getArgumentsAndReturnSizes() {
624625
* @return the descriptor corresponding to this Java type.
625626
*/
626627
public String getDescriptor() {
627-
StringBuffer buf = new StringBuffer();
628-
getDescriptor(buf);
629-
return buf.toString();
628+
StringBuilder sb = new StringBuilder();
629+
getDescriptor(sb);
630+
return sb.toString();
630631
}
631632

632633
/**
@@ -642,34 +643,34 @@ public String getDescriptor() {
642643
*/
643644
public static String getMethodDescriptor(final Type returnType,
644645
final Type... argumentTypes) {
645-
StringBuffer buf = new StringBuffer();
646-
buf.append('(');
646+
StringBuilder sb = new StringBuilder();
647+
sb.append('(');
647648
for (int i = 0; i < argumentTypes.length; ++i) {
648-
argumentTypes[i].getDescriptor(buf);
649+
argumentTypes[i].getDescriptor(sb);
649650
}
650-
buf.append(')');
651-
returnType.getDescriptor(buf);
652-
return buf.toString();
651+
sb.append(')');
652+
returnType.getDescriptor(sb);
653+
return sb.toString();
653654
}
654655

655656
/**
656657
* Appends the descriptor corresponding to this Java type to the given
657-
* string buffer.
658+
* string builder.
658659
*
659-
* @param buf
660-
* the string buffer to which the descriptor must be appended.
660+
* @param sb
661+
* the string builder to which the descriptor must be appended.
661662
*/
662-
private void getDescriptor(final StringBuffer buf) {
663+
private void getDescriptor(final StringBuilder sb) {
663664
if (this.buf == null) {
664665
// descriptor is in byte 3 of 'off' for primitive types (buf ==
665666
// null)
666-
buf.append((char) ((off & 0xFF000000) >>> 24));
667+
sb.append((char) ((off & 0xFF000000) >>> 24));
667668
} else if (sort == OBJECT) {
668-
buf.append('L');
669-
buf.append(this.buf, off, len);
670-
buf.append(';');
669+
sb.append('L');
670+
sb.append(this.buf, off, len);
671+
sb.append(';');
671672
} else { // sort == ARRAY || sort == METHOD
672-
buf.append(this.buf, off, len);
673+
sb.append(this.buf, off, len);
673674
}
674675
}
675676

@@ -699,9 +700,9 @@ public static String getInternalName(final Class<?> c) {
699700
* @return the descriptor corresponding to the given class.
700701
*/
701702
public static String getDescriptor(final Class<?> c) {
702-
StringBuffer buf = new StringBuffer();
703-
getDescriptor(buf, c);
704-
return buf.toString();
703+
StringBuilder sb = new StringBuilder();
704+
getDescriptor(sb, c);
705+
return sb.toString();
705706
}
706707

707708
/**
@@ -713,12 +714,12 @@ public static String getDescriptor(final Class<?> c) {
713714
*/
714715
public static String getConstructorDescriptor(final Constructor<?> c) {
715716
Class<?>[] parameters = c.getParameterTypes();
716-
StringBuffer buf = new StringBuffer();
717-
buf.append('(');
717+
StringBuilder sb = new StringBuilder();
718+
sb.append('(');
718719
for (int i = 0; i < parameters.length; ++i) {
719-
getDescriptor(buf, parameters[i]);
720+
getDescriptor(sb, parameters[i]);
720721
}
721-
return buf.append(")V").toString();
722+
return sb.append(")V").toString();
722723
}
723724

724725
/**
@@ -730,25 +731,25 @@ public static String getConstructorDescriptor(final Constructor<?> c) {
730731
*/
731732
public static String getMethodDescriptor(final Method m) {
732733
Class<?>[] parameters = m.getParameterTypes();
733-
StringBuffer buf = new StringBuffer();
734-
buf.append('(');
734+
StringBuilder sb = new StringBuilder();
735+
sb.append('(');
735736
for (int i = 0; i < parameters.length; ++i) {
736-
getDescriptor(buf, parameters[i]);
737+
getDescriptor(sb, parameters[i]);
737738
}
738-
buf.append(')');
739-
getDescriptor(buf, m.getReturnType());
740-
return buf.toString();
739+
sb.append(')');
740+
getDescriptor(sb, m.getReturnType());
741+
return sb.toString();
741742
}
742743

743744
/**
744-
* Appends the descriptor of the given class to the given string buffer.
745+
* Appends the descriptor of the given class to the given string builder.
745746
*
746-
* @param buf
747+
* @param sb
747748
* the string buffer to which the descriptor must be appended.
748749
* @param c
749750
* the class whose descriptor must be computed.
750751
*/
751-
private static void getDescriptor(final StringBuffer buf, final Class<?> c) {
752+
private static void getDescriptor(final StringBuilder sb, final Class<?> c) {
752753
Class<?> d = c;
753754
while (true) {
754755
if (d.isPrimitive()) {
@@ -772,20 +773,20 @@ private static void getDescriptor(final StringBuffer buf, final Class<?> c) {
772773
} else /* if (d == Long.TYPE) */{
773774
car = 'J';
774775
}
775-
buf.append(car);
776+
sb.append(car);
776777
return;
777778
} else if (d.isArray()) {
778-
buf.append('[');
779+
sb.append('[');
779780
d = d.getComponentType();
780781
} else {
781-
buf.append('L');
782+
sb.append('L');
782783
String name = d.getName();
783784
int len = name.length();
784785
for (int i = 0; i < len; ++i) {
785786
char car = name.charAt(i);
786-
buf.append(car == '.' ? '/' : car);
787+
sb.append(car == '.' ? '/' : car);
787788
}
788-
buf.append(';');
789+
sb.append(';');
789790
return;
790791
}
791792
}

0 commit comments

Comments
 (0)