Archiviert
13
0

Fixed a bug causing a StackOverflowException on packet construction.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-10-17 09:53:59 +02:00
Ursprung d5028b584d
Commit 69a5675161
2 geänderte Dateien mit 23 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -67,6 +67,16 @@ public abstract class CompiledStructureModifier<TField> extends StructureModifie
else
return (TField) result;
}
/**
* Read the given field index using reflection.
* @param index - index of field.
* @return Resulting value.
* @throws FieldAccessException The field doesn't exist, or it cannot be accessed under the current security contraints.
*/
protected Object readReflected(int index) throws FieldAccessException {
return super.read(index);
}
protected abstract Object readGenerated(int fieldIndex) throws FieldAccessException;
@ -78,6 +88,17 @@ public abstract class CompiledStructureModifier<TField> extends StructureModifie
return writeGenerated(index, value);
}
/**
* Write the given field using reflection.
* @param index - index of field.
* @param value - new value.
* @throws FieldAccessException The field doesn't exist, or it cannot be accessed under the current security contraints.
*/
@SuppressWarnings("unchecked")
protected void writeReflected(int index, Object value) throws FieldAccessException {
super.write(index, (TField) value);
}
protected abstract StructureModifier<TField> writeGenerated(int index, Object value) throws FieldAccessException;
@Override

Datei anzeigen

@ -335,8 +335,7 @@ public final class StructureCompiler {
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitVarInsn(Opcodes.ILOAD, 1);
mv.visitVarInsn(Opcodes.ALOAD, 2);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, COMPILED_CLASS, "write", "(ILjava/lang/Object;)L" + SUPER_CLASS + ";");
mv.visitInsn(Opcodes.POP);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, COMPILED_CLASS, "writeReflected", "(ILjava/lang/Object;)V;");
}
mv.visitJumpInsn(Opcodes.GOTO, returnLabel);
@ -408,7 +407,7 @@ public final class StructureCompiler {
// We have to use reflection for private and protected fields.
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitVarInsn(Opcodes.ILOAD, 1);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, COMPILED_CLASS, "read", "(I)Ljava/lang/Object;");
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, COMPILED_CLASS, "readReflected", "(I)Ljava/lang/Object;");
}
mv.visitInsn(Opcodes.ARETURN);