Re: Generated dnProvideFields method appears to not handle case where fieldNumbers array is null (i.e. class has no attributes) in DN 5.1.6


Page bloom
 

I found the code that's adding the dnProvideFields methods during BCE:

org.datanucleus.enhancer.methods.ProvideFields.java

The execute method is doing the comparison with null here:

 

    public void execute()

    {

        visitor.visitCode();

 

        Label l0 = new Label();

        visitor.visitLabel(l0);

        visitor.visitVarInsn(Opcodes.ALOAD, 1);

        Label l1 = new Label();

        visitor.visitJumpInsn(Opcodes.IFNONNULL, l1);

        visitor.visitTypeInsn(Opcodes.NEW, "java/lang/IllegalArgumentException");

        visitor.visitInsn(Opcodes.DUP);

        visitor.visitLdcInsn("argment is null");

        visitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/IllegalArgumentException",

            "<init>", "(Ljava/lang/String;)V");

        visitor.visitInsn(Opcodes.ATHROW);

It's all in Java VM machine language (obviously much more efficient than performing a compile phase during enhancement) which makes for interesting reading ;)

I'm wondering if it's better to just change StateManagerImpl so that it passes an empty Array into dnProvideFields rather than changing the enhancer...

Join main@datanucleus.groups.io to automatically receive all group messages.