mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 11:36:51 +01:00
Fixed a bug causing a StackOverflowException on packet construction.
This commit is contained in:
parent
d5028b584d
commit
69a5675161
@ -68,6 +68,16 @@ public abstract class CompiledStructureModifier<TField> extends StructureModifie
|
|||||||
return (TField) result;
|
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;
|
protected abstract Object readGenerated(int fieldIndex) throws FieldAccessException;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -78,6 +88,17 @@ public abstract class CompiledStructureModifier<TField> extends StructureModifie
|
|||||||
return writeGenerated(index, value);
|
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;
|
protected abstract StructureModifier<TField> writeGenerated(int index, Object value) throws FieldAccessException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -335,8 +335,7 @@ public final class StructureCompiler {
|
|||||||
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
||||||
mv.visitVarInsn(Opcodes.ILOAD, 1);
|
mv.visitVarInsn(Opcodes.ILOAD, 1);
|
||||||
mv.visitVarInsn(Opcodes.ALOAD, 2);
|
mv.visitVarInsn(Opcodes.ALOAD, 2);
|
||||||
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, COMPILED_CLASS, "write", "(ILjava/lang/Object;)L" + SUPER_CLASS + ";");
|
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, COMPILED_CLASS, "writeReflected", "(ILjava/lang/Object;)V;");
|
||||||
mv.visitInsn(Opcodes.POP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mv.visitJumpInsn(Opcodes.GOTO, returnLabel);
|
mv.visitJumpInsn(Opcodes.GOTO, returnLabel);
|
||||||
@ -408,7 +407,7 @@ public final class StructureCompiler {
|
|||||||
// We have to use reflection for private and protected fields.
|
// We have to use reflection for private and protected fields.
|
||||||
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
||||||
mv.visitVarInsn(Opcodes.ILOAD, 1);
|
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);
|
mv.visitInsn(Opcodes.ARETURN);
|
||||||
|
Loading…
Reference in New Issue
Block a user