INLINE Constant *Constant::dispatchMarshal(Stream &stream, JVM_U1 tag) { Constant *constant = NULL; switch(tag) { case 7: constant = new ConstantClass(); break; case 9: constant = new ConstantFieldRef(); break; case 10: constant = new ConstantMethodRef(); break; case 11: constant = new ConstantInterfaceMethodRef(); break; case 8: constant = new ConstantString(); break; case 3: constant = new ConstantInteger(); break; case 4: constant = new ConstantFloat(); break; case 5: constant = new ConstantLong(); break; case 6: constant = new ConstantDouble(); break; case 12: constant = new ConstantNameAndType(); break; case 1: constant = new ConstantUtf8(); break; case 15: constant = new ConstantMethodHandle(); break; case 16: constant = new ConstantMethodType(); break; case 18: constant = new ConstantInvokeDynamic(); break; default: ERROR("tag is %d, this should not happened!", tag); break; } if(constant != NULL) { constant->tag_ = tag; if(constant->marshal(stream) == false) { ERROR("constant %d marshal failed! this constant object will be removed.", tag); delete constant; return NULL; } } return constant; }