protected void addFields(ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode) { // The field representing the underlying instance or special method // handling proxyClassType.addField(AccessFlag.PRIVATE, METHOD_HANDLER_FIELD_NAME, getMethodHandlerType()); if (useConstructedFlag()) { // field used to indicate that super() has been called proxyClassType.addField(AccessFlag.PRIVATE, CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); } }
protected void addFields(ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode) { // The field representing the underlying instance or special method // handling proxyClassType.addField(AccessFlag.PRIVATE, METHOD_HANDLER_FIELD_NAME, getMethodHandlerType()); if (useConstructedFlag()) { // field used to indicate that super() has been called proxyClassType.addField(AccessFlag.PRIVATE, CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); } }
protected void addFields(ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode) { // The field representing the underlying instance or special method // handling proxyClassType.addField(AccessFlag.PRIVATE, METHOD_HANDLER_FIELD_NAME, getMethodHandlerType()); if (useConstructedFlag()) { // field used to indicate that super() has been called proxyClassType.addField(AccessFlag.PRIVATE, CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); } }
protected void addFields(ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode) { // The field representing the underlying instance or special method // handling proxyClassType.addField(AccessFlag.PRIVATE, METHOD_HANDLER_FIELD_NAME, getMethodHandlerType()); if (useConstructedFlag()) { // field used to indicate that super() has been called proxyClassType.addField(AccessFlag.PRIVATE, CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); } }
protected void addFields(ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode) { // The field representing the underlying instance or special method // handling proxyClassType.addField(AccessFlag.PRIVATE, METHOD_HANDLER_FIELD_NAME, getMethodHandlerType()); if (useConstructedFlag()) { // field used to indicate that super() has been called proxyClassType.addField(AccessFlag.PRIVATE, CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); } }
protected void addFields(ClassFile proxyClassType, List<DeferredBytecode> initialValueBytecode) { // The field representing the underlying instance or special method // handling proxyClassType.addField(AccessFlag.PRIVATE, METHOD_HANDLER_FIELD_NAME, getMethodHandlerType()); if (useConstructedFlag()) { // field used to indicate that super() has been called proxyClassType.addField(AccessFlag.PRIVATE, CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); } }
try { if (getBeanType().isInterface()) { ConstructorUtils.addDefaultConstructor(proxyClassType, initialValueBytecode, !useConstructedFlag()); } else { boolean constructorFound = false; exceptions[i] = constructor.getExceptionTypes()[i].getName(); ConstructorUtils.addConstructor(BytecodeUtils.VOID_CLASS_DESCRIPTOR, DescriptorUtils.parameterDescriptors(constructor.getParameterTypes()), exceptions, proxyClassType, initialValueBytecode, !useConstructedFlag());
try { if (getBeanType().isInterface()) { ConstructorUtils.addDefaultConstructor(proxyClassType, initialValueBytecode, !useConstructedFlag()); } else { boolean constructorFound = false; exceptions[i] = constructor.getExceptionTypes()[i].getName(); ConstructorUtils.addConstructor(BytecodeUtils.VOID_CLASS_DESCRIPTOR, DescriptorUtils.parameterDescriptors(constructor.getParameterTypes()), exceptions, proxyClassType, initialValueBytecode, !useConstructedFlag());
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
/** * Adds the following code to a delegating method: * <p/> * <code> * if(!this.constructed) return super.thisMethod() * </code> * <p/> * This means that the proxy will not start to delegate to the underlying * bean instance until after the constructor has finished. */ protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) { if (!useConstructedFlag()) { return; } // now create the conditional final CodeAttribute cond = classMethod.getCodeAttribute(); cond.aload(0); cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); // jump if the proxy constructor has finished BranchEnd jumpMarker = cond.ifne(); // generate the invokespecial call to the super class method // this is run when the proxy is being constructed cond.aload(0); cond.loadMethodParameters(); cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor()); cond.returnInstruction(); cond.branchEnd(jumpMarker); }
/** * Adds the following code to a delegating method: * <p/> * <code> * if(!this.constructed) return super.thisMethod() * </code> * <p/> * This means that the proxy will not start to delegate to the underlying * bean instance until after the constructor has finished. */ protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) { if (!useConstructedFlag()) { return; } // now create the conditional final CodeAttribute cond = classMethod.getCodeAttribute(); cond.aload(0); cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); // jump if the proxy constructor has finished BranchEnd jumpMarker = cond.ifne(); // generate the invokespecial call to the super class method // this is run when the proxy is being constructed cond.aload(0); cond.loadMethodParameters(); cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor()); cond.returnInstruction(); cond.branchEnd(jumpMarker); }
/** * Adds the following code to a delegating method: * <p/> * <code> * if(!this.constructed) return super.thisMethod() * </code> * <p/> * This means that the proxy will not start to delegate to the underlying * bean instance until after the constructor has finished. */ protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) { if (!useConstructedFlag()) { return; } // now create the conditional final CodeAttribute cond = classMethod.getCodeAttribute(); cond.aload(0); cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); // jump if the proxy constructor has finished BranchEnd jumpMarker = cond.ifne(); // generate the invokespecial call to the super class method // this is run when the proxy is being constructed cond.aload(0); cond.loadMethodParameters(); cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor()); cond.returnInstruction(); cond.branchEnd(jumpMarker); }
/** * Adds the following code to a delegating method: * <p/> * <code> * if(!this.constructed) return super.thisMethod() * </code> * <p/> * This means that the proxy will not start to delegate to the underlying * bean instance until after the constructor has finished. */ protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) { if (!useConstructedFlag()) { return; } // now create the conditional final CodeAttribute cond = classMethod.getCodeAttribute(); cond.aload(0); cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); // jump if the proxy constructor has finished BranchEnd jumpMarker = cond.ifne(); // generate the invokespecial call to the super class method // this is run when the proxy is being constructed cond.aload(0); cond.loadMethodParameters(); cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor()); cond.returnInstruction(); cond.branchEnd(jumpMarker); }
/** * Adds the following code to a delegating method: * <p/> * <code> * if(!this.constructed) return super.thisMethod() * </code> * <p/> * This means that the proxy will not start to delegate to the underlying * bean instance until after the constructor has finished. */ protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) { if (!useConstructedFlag()) { return; } // now create the conditional final CodeAttribute cond = classMethod.getCodeAttribute(); cond.aload(0); cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); // jump if the proxy constructor has finished BranchEnd jumpMarker = cond.ifne(); // generate the invokespecial call to the super class method // this is run when the proxy is being constructed cond.aload(0); cond.loadMethodParameters(); cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor()); cond.returnInstruction(); cond.branchEnd(jumpMarker); }
/** * Adds the following code to a delegating method: * <p/> * <code> * if(!this.constructed) return super.thisMethod() * </code> * <p/> * This means that the proxy will not start to delegate to the underlying * bean instance until after the constructor has finished. */ protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) { if (!useConstructedFlag()) { return; } // now create the conditional final CodeAttribute cond = classMethod.getCodeAttribute(); cond.aload(0); cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR); // jump if the proxy constructor has finished BranchEnd jumpMarker = cond.ifne(); // generate the invokespecial call to the super class method // this is run when the proxy is being constructed cond.aload(0); cond.loadMethodParameters(); cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor()); cond.returnInstruction(); cond.branchEnd(jumpMarker); }