Ver código fonte

Compacting/clone has a problem when the method index is zero.

This looks like an inner class trying to describe its outer class rather
than a method.


git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@242 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
tags/rel_3_17_1_ga
adrian 18 anos atrás
pai
commit
2b3afd3a5d

+ 20
- 0
src/main/javassist/bytecode/EnclosingMethodAttribute.java Ver arquivo

@@ -55,6 +55,24 @@ public class EnclosingMethodAttribute extends AttributeInfo {
set(bvalue);
}

/**
* Constructs an EnclosingMethod attribute.
*
* @param cp a constant pool table.
* @param className the name of the innermost enclosing class.
*/
public EnclosingMethodAttribute(ConstPool cp, String className) {
super(cp, tag);
int ci = cp.addClassInfo(className);
int ni = 0;
byte[] bvalue = new byte[4];
bvalue[0] = (byte)(ci >>> 8);
bvalue[1] = (byte)ci;
bvalue[2] = (byte)(ni >>> 8);
bvalue[3] = (byte)ni;
set(bvalue);
}

/**
* Returns the value of <code>class_index</code>.
*/
@@ -105,6 +123,8 @@ public class EnclosingMethodAttribute extends AttributeInfo {
* class names.
*/
public AttributeInfo copy(ConstPool newCp, Map classnames) {
if (methodIndex() == 0)
return new EnclosingMethodAttribute(newCp, className());
return new EnclosingMethodAttribute(newCp, className(),
methodName(), methodDescriptor());
}

Carregando…
Cancelar
Salvar