Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Commit e8ab57a

Browse files
committed
Merge pull request #5 from lrytz/asm-5.0.4
Upgrade to ASM 5.0.4
2 parents 169cf51 + aceecb4 commit e8ab57a

17 files changed

+84
-56
lines changed

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ This makes it easy to see how our fork differs from the official release.
2222
The current sources are based on the following version of ASM ([browse tags here](http://websvn.ow2.org/listing.php?repname=asm&path=%2Ftags%2F&peg=1748)):
2323

2424
```
25-
Version 5.0.3, SVN r1748, tags/ASM_5_0_3
25+
Version 5.0.4, SVN r1779, tags/ASM_5_0_4
2626
```
2727

28+
Previous ASM Upgrade PR: https://github.com/scala/scala-asm/pull/5
29+
2830
## Upgrading ASM
2931

3032
Start by deleting all source files and copy the ones from the latest ASM release.
3133

32-
The original ASM sources are in an SVN repository, which is mirrored here: https://github.com/lrytz/asm.
34+
The original ASM sources are in an [SVN repository](http://forge.ow2.org/plugins/scmsvn/index.php?group_id=23), which is mirrored here: https://github.com/lrytz/asm.
3335
You can use this mirror, your own git-svn mirror, or the original SVN repository to grab the sources of a new ASM version.
3436
A description how to work with the git-svn clone is here: https://github.com/lrytz/asm/issues/1.
3537

@@ -39,27 +41,24 @@ Excluded Files (don't copy):
3941
* `org/objectweb/asm/optimizer`
4042
* `org/objectweb/asm/xml`
4143

42-
*The below will change once a first is done in the new `scala/scala-asm` repository.*
43-
*In the new repository, it probably makes sense to only squash the "Re-packaging and cosmetic changes".*
44-
*The "actual changes" can then stay in the commit history.*
45-
46-
Check the commit history of `src/asm`: https://github.com/scala/scala/commits/2.11.x/src/asm.
47-
Find the previous commit that upgraded ASM and take a look at its commit message.
48-
It should be a squashed version of a pull request that shows the precise procedure how the last upgrade was made.
44+
Take a look at the previous PR that upgraded ASM [(see above)](#current-version).
45+
Follow the upgrade procedure in the same way.
4946

50-
Re-packaging and cosmetic changes:
47+
The re-packaging and cleanup commits can be applied using the following commands:
5148
* convert line endings (there are some `CRLF`)
52-
`find src/asm/scala/tools/asm -name '*.java' | xargs dos2unix`
49+
`find src -name '*.java' | xargs dos2unix`
5350
* change package clauses
54-
`find src/asm/scala/tools/asm -name '*.java' | xargs sed -i '' -e 's/package org\.objectweb\.asm/package scala.tools.asm/'`
51+
`find src -name '*.java' | xargs sed -i '' -e 's/package org\.objectweb\.asm/package scala.tools.asm/'`
5552
* update imports
56-
`find src/asm/scala/tools/asm -name '*.java' | xargs sed -i '' -e 's/import org\.objectweb\.asm/import scala.tools.asm/'`
53+
`find src -name '*.java' | xargs sed -i '' -e 's/import org\.objectweb\.asm/import scala.tools.asm/'`
5754
* update `@links`, `@associates`
58-
`find src/asm/scala/tools/asm -name '*.java' | xargs sed -i '' -e 's/@link org\.objectweb\.asm/@link scala.tools.asm/'`
59-
`find src/asm/scala/tools/asm -name '*.java' | xargs sed -i '' -e 's/@associates org\.objectweb\.asm/@associates scala.tools.asm/'`
55+
`find src -name '*.java' | xargs sed -i '' -e 's/@link org\.objectweb\.asm/@link scala.tools.asm/'`
56+
`find src -name '*.java' | xargs sed -i '' -e 's/@associates org\.objectweb\.asm/@associates scala.tools.asm/'`
6057
* remove trailing whitespace
61-
`find src/asm/scala/tools/asm -name '*.java' | xargs sed -i '' -e 's/[ ]*$//'`
58+
`find src -name '*.java' | xargs sed -i '' -e 's/[ ]*$//'`
59+
60+
Cherry-pick the actual changes that we have in our fork:
61+
* Include the commits labelled `[asm-cherry-pick]` in the previous upgrade PR
62+
* Include the changes to `src` that were added since the last upgrade, and label them `[asm-cherry-pick]`
6263

63-
Include the actual changes that we have in our repostiory
64-
* Include the commits labelled `[asm-cherry-pick]` in the non-squashed PR of the previous upgrade
65-
* Include the changes that were added to src/asm since the last upgrade and label them `[asm-cherry-pick]`
64+
Update the ["Current Version"](#current-version) section of this README.

src/main/java/scala/tools/asm/ClassReader.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,14 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
11701170
if (labels[label] == null) {
11711171
readLabel(label, labels).status |= Label.DEBUG;
11721172
}
1173-
labels[label].line = readUnsignedShort(v + 12);
1173+
Label l = labels[label];
1174+
while (l.line > 0) {
1175+
if (l.next == null) {
1176+
l.next = new Label();
1177+
}
1178+
l = l.next;
1179+
}
1180+
l.line = readUnsignedShort(v + 12);
11741181
v += 4;
11751182
}
11761183
}
@@ -1285,9 +1292,15 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
12851292
// visits the label and line number for this offset, if any
12861293
Label l = labels[offset];
12871294
if (l != null) {
1295+
Label next = l.next;
1296+
l.next = null;
12881297
mv.visitLabel(l);
12891298
if ((context.flags & SKIP_DEBUG) == 0 && l.line > 0) {
12901299
mv.visitLineNumber(l.line, l);
1300+
while (next != null) {
1301+
mv.visitLineNumber(next.line, l);
1302+
next = next.next;
1303+
}
12911304
}
12921305
}
12931306

@@ -1828,8 +1841,7 @@ private int readAnnotationValue(int v, final char[] buf, final String name,
18281841
v += 2;
18291842
break;
18301843
case 'B': // pointer to CONSTANT_Byte
1831-
av.visit(name,
1832-
new Byte((byte) readInt(items[readUnsignedShort(v)])));
1844+
av.visit(name, (byte) readInt(items[readUnsignedShort(v)]));
18331845
v += 2;
18341846
break;
18351847
case 'Z': // pointer to CONSTANT_Boolean
@@ -1839,13 +1851,11 @@ private int readAnnotationValue(int v, final char[] buf, final String name,
18391851
v += 2;
18401852
break;
18411853
case 'S': // pointer to CONSTANT_Short
1842-
av.visit(name, new Short(
1843-
(short) readInt(items[readUnsignedShort(v)])));
1854+
av.visit(name, (short) readInt(items[readUnsignedShort(v)]));
18441855
v += 2;
18451856
break;
18461857
case 'C': // pointer to CONSTANT_Char
1847-
av.visit(name, new Character(
1848-
(char) readInt(items[readUnsignedShort(v)])));
1858+
av.visit(name, (char) readInt(items[readUnsignedShort(v)]));
18491859
v += 2;
18501860
break;
18511861
case 's': // pointer to CONSTANT_Utf8
@@ -2469,13 +2479,13 @@ public Object readConst(final int item, final char[] buf) {
24692479
int index = items[item];
24702480
switch (b[index - 1]) {
24712481
case ClassWriter.INT:
2472-
return new Integer(readInt(index));
2482+
return readInt(index);
24732483
case ClassWriter.FLOAT:
2474-
return new Float(Float.intBitsToFloat(readInt(index)));
2484+
return Float.intBitsToFloat(readInt(index));
24752485
case ClassWriter.LONG:
2476-
return new Long(readLong(index));
2486+
return readLong(index);
24772487
case ClassWriter.DOUBLE:
2478-
return new Double(Double.longBitsToDouble(readLong(index)));
2488+
return Double.longBitsToDouble(readLong(index));
24792489
case ClassWriter.CLASS:
24802490
return Type.getObjectType(readUTF8(index, buf));
24812491
case ClassWriter.STR:

src/main/java/scala/tools/asm/Item.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ void set(final double doubleVal) {
201201
* @param strVal3
202202
* third part of the value of this item.
203203
*/
204+
@SuppressWarnings("fallthrough")
204205
void set(final int type, final String strVal1, final String strVal2,
205206
final String strVal3) {
206207
this.type = type;

src/main/java/scala/tools/asm/Label.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ public class Label {
131131
int status;
132132

133133
/**
134-
* The line number corresponding to this label, if known.
134+
* The line number corresponding to this label, if known. If there are
135+
* several lines, each line is stored in a separate label, all linked via
136+
* their next field (these links are created in ClassReader and removed just
137+
* before visitLabel is called, so that this does not impact the rest of the
138+
* code).
135139
*/
136140
int line;
137141

@@ -239,7 +243,8 @@ public class Label {
239243
* The next basic block in the basic block stack. This stack is used in the
240244
* main loop of the fix point algorithm used in the second step of the
241245
* control flow analysis algorithms. It is also used in
242-
* {@link #visitSubroutine} to avoid using a recursive method.
246+
* {@link #visitSubroutine} to avoid using a recursive method, and in
247+
* ClassReader to temporarily store multiple source lines for a label.
243248
*
244249
* @see MethodWriter#visitMaxs
245250
*/

src/main/java/scala/tools/asm/MethodVisitor.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@
3333
* A visitor to visit a Java method. The methods of this class must be called in
3434
* the following order: ( <tt>visitParameter</tt> )* [
3535
* <tt>visitAnnotationDefault</tt> ] ( <tt>visitAnnotation</tt> |
36-
* <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* [
37-
* <tt>visitCode</tt> ( <tt>visitFrame</tt> | <tt>visit<i>X</i>Insn</tt> |
38-
* <tt>visitLabel</tt> | <tt>visitInsnAnnotation</tt> |
39-
* <tt>visitTryCatchBlock</tt> | <tt>visitTryCatchBlockAnnotation</tt> |
40-
* <tt>visitLocalVariable</tt> | <tt>visitLocalVariableAnnotation</tt> |
41-
* <tt>visitLineNumber</tt> )* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In
42-
* addition, the <tt>visit<i>X</i>Insn</tt> and <tt>visitLabel</tt> methods must
43-
* be called in the sequential order of the bytecode instructions of the visited
44-
* code, <tt>visitInsnAnnotation</tt> must be called <i>after</i> the annotated
36+
* <tt>visitParameterAnnotation</tt> <tt>visitTypeAnnotation</tt> |
37+
* <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visitFrame</tt> |
38+
* <tt>visit<i>X</i>Insn</tt> | <tt>visitLabel</tt> |
39+
* <tt>visitInsnAnnotation</tt> | <tt>visitTryCatchBlock</tt> |
40+
* <tt>visitTryCatchAnnotation</tt> | <tt>visitLocalVariable</tt> |
41+
* <tt>visitLocalVariableAnnotation</tt> | <tt>visitLineNumber</tt> )*
42+
* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In addition, the
43+
* <tt>visit<i>X</i>Insn</tt> and <tt>visitLabel</tt> methods must be called in
44+
* the sequential order of the bytecode instructions of the visited code,
45+
* <tt>visitInsnAnnotation</tt> must be called <i>after</i> the annotated
4546
* instruction, <tt>visitTryCatchBlock</tt> must be called <i>before</i> the
4647
* labels passed as arguments have been visited,
4748
* <tt>visitTryCatchBlockAnnotation</tt> must be called <i>after</i> the

src/main/java/scala/tools/asm/MethodWriter.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,11 +2717,13 @@ private void resizeInstructions() {
27172717
l = l.successor;
27182718
}
27192719
// Update the offsets in the uninitialized types
2720-
for (i = 0; i < cw.typeTable.length; ++i) {
2721-
Item item = cw.typeTable[i];
2722-
if (item != null && item.type == ClassWriter.TYPE_UNINIT) {
2723-
item.intVal = getNewOffset(allIndexes, allSizes, 0,
2724-
item.intVal);
2720+
if (cw.typeTable != null) {
2721+
for (i = 0; i < cw.typeTable.length; ++i) {
2722+
Item item = cw.typeTable[i];
2723+
if (item != null && item.type == ClassWriter.TYPE_UNINIT) {
2724+
item.intVal = getNewOffset(allIndexes, allSizes, 0,
2725+
item.intVal);
2726+
}
27252727
}
27262728
}
27272729
// The stack map frames are not serialized yet, so we don't need

src/main/java/scala/tools/asm/TypePath.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ public static TypePath fromString(final String typePath) {
152152
typeArg = typeArg * 10 + c - '0';
153153
i += 1;
154154
}
155+
if (i < n && typePath.charAt(i) == ';') {
156+
i += 1;
157+
}
155158
out.put11(TYPE_ARGUMENT, typeArg);
156159
}
157160
}
@@ -164,7 +167,7 @@ public static TypePath fromString(final String typePath) {
164167
* ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE
165168
* INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps
166169
* with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type
167-
* argument index in decimal form.
170+
* argument index in decimal form followed by ';'.
168171
*/
169172
@Override
170173
public String toString() {
@@ -182,7 +185,7 @@ public String toString() {
182185
result.append('*');
183186
break;
184187
case TYPE_ARGUMENT:
185-
result.append(getStepArgument(i));
188+
result.append(getStepArgument(i)).append(';');
186189
break;
187190
default:
188191
result.append('_');

src/main/java/scala/tools/asm/signature/SignatureVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* <ul>
4040
* <li><i>ClassSignature</i> = ( <tt>visitFormalTypeParameter</tt>
4141
* <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* (
42-
* <tt>visitSuperClass</tt> <tt>visitInterface</tt>* )</li>
42+
* <tt>visitSuperclass</tt> <tt>visitInterface</tt>* )</li>
4343
* <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt>
4444
* <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* (
4545
* <tt>visitParameterType</tt>* <tt>visitReturnType</tt>

src/main/java/scala/tools/asm/tree/AnnotationNode.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,13 @@ static void accept(final AnnotationVisitor av, final String name,
218218
an.accept(av.visitAnnotation(name, an.desc));
219219
} else if (value instanceof List) {
220220
AnnotationVisitor v = av.visitArray(name);
221-
List<?> array = (List<?>) value;
222-
for (int j = 0; j < array.size(); ++j) {
223-
accept(v, null, array.get(j));
221+
if (v != null) {
222+
List<?> array = (List<?>) value;
223+
for (int j = 0; j < array.size(); ++j) {
224+
accept(v, null, array.get(j));
225+
}
226+
v.visitEnd();
224227
}
225-
v.visitEnd();
226228
} else {
227229
av.visit(name, value);
228230
}

src/main/java/scala/tools/asm/tree/InsnList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ public void resetLabels() {
529529
}
530530

531531
// this class is not generified because it will create bridges
532+
@SuppressWarnings("rawtypes")
532533
private final class InsnListIterator implements ListIterator {
533534

534535
AbstractInsnNode next;

src/main/java/scala/tools/asm/tree/LookupSwitchInsnNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public LookupSwitchInsnNode(final LabelNode dflt, final int[] keys,
8181
: labels.length);
8282
if (keys != null) {
8383
for (int i = 0; i < keys.length; ++i) {
84-
this.keys.add(new Integer(keys[i]));
84+
this.keys.add(keys[i]);
8585
}
8686
}
8787
if (labels != null) {

src/main/java/scala/tools/asm/tree/MethodInsnNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public int getType() {
132132
@Override
133133
public void accept(final MethodVisitor mv) {
134134
mv.visitMethodInsn(opcode, owner, name, desc, itf);
135+
acceptAnnotations(mv);
135136
}
136137

137138
@Override

src/main/java/scala/tools/asm/tree/MethodNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ public AnnotationVisitor visitTypeAnnotation(int typeRef,
370370
}
371371

372372
@Override
373+
@SuppressWarnings("unchecked")
373374
public AnnotationVisitor visitParameterAnnotation(final int parameter,
374375
final String desc, final boolean visible) {
375376
AnnotationNode an = new AnnotationNode(desc);

src/main/java/scala/tools/asm/tree/analysis/Analyzer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public Analyzer(final Interpreter<V> interpreter) {
102102
* @throws AnalyzerException
103103
* if a problem occurs during the analysis.
104104
*/
105+
@SuppressWarnings("unchecked")
105106
public Frame<V>[] analyze(final String owner, final MethodNode m)
106107
throws AnalyzerException {
107108
if ((m.access & (ACC_ABSTRACT | ACC_NATIVE)) != 0) {

src/main/java/scala/tools/asm/tree/analysis/Frame.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class Frame<V extends Value> {
8383
* @param nStack
8484
* the maximum stack size of the frame.
8585
*/
86+
@SuppressWarnings("unchecked")
8687
public Frame(final int nLocals, final int nStack) {
8788
this.values = (V[]) new Value[nLocals + nStack];
8889
this.locals = nLocals;

src/main/java/scala/tools/asm/util/CheckMethodAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ public void visitLabel(final Label label) {
773773
if (labels.get(label) != null) {
774774
throw new IllegalArgumentException("Already visited label");
775775
}
776-
labels.put(label, new Integer(insnCount));
776+
labels.put(label, insnCount);
777777
super.visitLabel(label);
778778
}
779779

src/main/java/scala/tools/asm/util/Textifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ public Textifier visitParameterAnnotation(final int parameter,
703703
Textifier t = createTextifier();
704704
text.add(t.getText());
705705
text.add(visible ? ") // parameter " : ") // invisible, parameter ");
706-
text.add(new Integer(parameter));
706+
text.add(parameter);
707707
text.add("\n");
708708
return t;
709709
}

0 commit comments

Comments
 (0)