/** * Write the generated bytecode. */ public void record() throws IOException { if (_managedType != _pc && getRedefine()) record(_managedType); record(_pc); if (_oids != null) for (Iterator itr = _oids.iterator(); itr.hasNext();) record((BCClass) itr.next()); }
/** * Write the generated bytecode. */ public void record() throws IOException { if (_managedType != _pc && getRedefine()) record(_managedType); record(_pc); if (_oids != null) for (Iterator itr = _oids.iterator(); itr.hasNext();) record((BCClass) itr.next()); }
/** * Write the generated bytecode. */ public void record() throws IOException { if (_managedType != _pc && getRedefine()) record(_managedType); record(_pc); if (_oids != null) for (Iterator itr = _oids.iterator(); itr.hasNext();) record((BCClass) itr.next()); }
/** * Write the generated bytecode. */ public void record() throws IOException { if (_managedType != _pc && getRedefine()) record(_managedType); record(_pc); if (_oids != null) for (Iterator itr = _oids.iterator(); itr.hasNext();) record((BCClass) itr.next()); }
/** * Write the generated bytecode. */ public void record() throws IOException { if (_managedType != _pc && getRedefine()) record(_managedType); record(_pc); if (_oids != null) for (Iterator itr = _oids.iterator(); itr.hasNext();) record((BCClass) itr.next()); }
/** * Adds synthetic field access methods that will replace all direct * field accesses. */ private void addAccessors() throws NoSuchMethodException { FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields() : _meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (getCreateSubclass()) { if (!getRedefine() && isPropertyAccess(fmds[i])) { addSubclassSetMethod(fmds[i]); addSubclassGetMethod(fmds[i]); } } else { addGetMethod(i, fmds[i]); addSetMethod(i, fmds[i]); } } }
/** * Adds synthetic field access methods that will replace all direct * field accesses. */ private void addAccessors() throws NoSuchMethodException { FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields() : _meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (getCreateSubclass()) { if (!getRedefine() && isPropertyAccess(fmds[i])) { addSubclassSetMethod(fmds[i]); addSubclassGetMethod(fmds[i]); } } else { addGetMethod(i, fmds[i]); addSetMethod(i, fmds[i]); } } }
/** * Adds synthetic field access methods that will replace all direct * field accesses. */ private void addAccessors() throws NoSuchMethodException { FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields() : _meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (getCreateSubclass()) { if (!getRedefine() && isPropertyAccess(fmds[i])) { addSubclassSetMethod(fmds[i]); addSubclassGetMethod(fmds[i]); } } else { addGetMethod(i, fmds[i]); addSetMethod(i, fmds[i]); } } }
/** * Adds synthetic field access methods that will replace all direct * field accesses. */ private void addAccessors() throws NoSuchMethodException { FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields() : _meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (getCreateSubclass()) { if (!getRedefine() && isPropertyAccess(fmds[i])) { addSubclassSetMethod(fmds[i]); addSubclassGetMethod(fmds[i]); } } else { addGetMethod(i, fmds[i]); addSetMethod(i, fmds[i]); } } }
/** * Adds synthetic field access methods that will replace all direct * field accesses. */ private void addAccessors() throws NoSuchMethodException { FieldMetaData[] fmds = getCreateSubclass() ? _meta.getFields() : _meta.getDeclaredFields(); for (int i = 0; i < fmds.length; i++) { if (getCreateSubclass()) { if (!getRedefine() && _meta.getAccessType() != ClassMetaData.ACCESS_FIELD) { addSubclassSetMethod(fmds[i]); addSubclassGetMethod(fmds[i]); } } else { addGetMethod(i, fmds[i]); addSetMethod(i, fmds[i]); } } }
/** * Adds a non-static getter that delegates to the super methods, and * performs any necessary field tracking. */ private void addSubclassGetMethod(FieldMetaData fmd) { String methName = "get" + StringUtils.capitalize(fmd.getName()); if (_managedType.getMethods(methName, new Class[0]).length == 0) methName = "is" + StringUtils.capitalize(fmd.getName()); BCMethod getter = _pc.declareMethod(methName, fmd.getDeclaredType(), null); setVisibilityToSuperMethod(getter); getter.makePublic(); Code code = getter.getCode(true); // if we're not already tracking field access via reflection, then we // must make the getter hook in lazy loading before accessing the super // method. if (!getRedefine()) addNotifyAccess(code, fmd); code.aload().setThis(); code.invokespecial().setMethod(_managedType.getType(), methName, fmd.getDeclaredType(), null); code.xreturn().setType(fmd.getDeclaredType()); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Adds a non-static getter that delegates to the super methods, and * performs any necessary field tracking. */ private void addSubclassGetMethod(FieldMetaData fmd) { String methName = "get" + StringUtils.capitalize(fmd.getName()); if (_managedType.getMethods(methName, new Class[0]).length == 0) methName = "is" + StringUtils.capitalize(fmd.getName()); BCMethod getter = _pc.declareMethod(methName, fmd.getDeclaredType(), null); setVisibilityToSuperMethod(getter); getter.makePublic(); Code code = getter.getCode(true); // if we're not already tracking field access via reflection, then we // must make the getter hook in lazy loading before accessing the super // method. if (!getRedefine()) addNotifyAccess(code, fmd); code.aload().setThis(); code.invokespecial().setMethod(_managedType.getType(), methName, fmd.getDeclaredType(), null); code.xreturn().setType(fmd.getDeclaredType()); code.calculateMaxLocals(); code.calculateMaxStack(); }
private void configureBCs() { if (!_bcsConfigured) { if (getRedefine()) { if (_managedType.getAttribute(REDEFINED_ATTRIBUTE) == null) _managedType.addAttribute(REDEFINED_ATTRIBUTE); else _isAlreadyRedefined = true; } if (getCreateSubclass()) { PCSubclassValidator val = new PCSubclassValidator( _meta, _managedType, _log, _fail); val.assertCanSubclass(); _pc = _managedType.getProject().loadClass( toPCSubclassName(_managedType.getType())); if (_pc.getSuperclassBC() != _managedType) { _pc.setSuperclass(_managedType); _pc.setAbstract(_managedType.isAbstract()); _pc.declareInterface(DynamicPersistenceCapable.class); } else { _isAlreadySubclassed = true; } } _bcsConfigured = true; } }
private void configureBCs() { if (!_bcsConfigured) { if (getRedefine()) { if (_managedType.getAttribute(REDEFINED_ATTRIBUTE) == null) _managedType.addAttribute(REDEFINED_ATTRIBUTE); else _isAlreadyRedefined = true; } if (getCreateSubclass()) { PCSubclassValidator val = new PCSubclassValidator( _meta, _managedType, _log, _fail); val.assertCanSubclass(); _pc = _managedType.getProject().loadClass( toPCSubclassName(_managedType.getType())); if (_pc.getSuperclassBC() != _managedType) { _pc.setSuperclass(_managedType); _pc.setAbstract(_managedType.isAbstract()); _pc.declareInterface(DynamicPersistenceCapable.class); } else { _isAlreadySubclassed = true; } } _bcsConfigured = true; } }
private void configureBCs() { if (!_bcsConfigured) { if (getRedefine()) { if (_managedType.getAttribute(REDEFINED_ATTRIBUTE) == null) _managedType.addAttribute(REDEFINED_ATTRIBUTE); else _isAlreadyRedefined = true; } if (getCreateSubclass()) { PCSubclassValidator val = new PCSubclassValidator( _meta, _managedType, _log, _fail); val.assertCanSubclass(); _pc = _managedType.getProject().loadClass( toPCSubclassName(_managedType.getType())); if (_pc.getSuperclassBC() != _managedType) { _pc.setSuperclass(_managedType); _pc.setAbstract(_managedType.isAbstract()); _pc.declareInterface(DynamicPersistenceCapable.class); } else { _isAlreadySubclassed = true; } } _bcsConfigured = true; } }
private void configureBCs() { if (!_bcsConfigured) { if (getRedefine()) { if (_managedType.getAttribute(REDEFINED_ATTRIBUTE) == null) _managedType.addAttribute(REDEFINED_ATTRIBUTE); else _isAlreadyRedefined = true; } if (getCreateSubclass()) { PCSubclassValidator val = new PCSubclassValidator( _meta, _managedType, _log, _fail); val.assertCanSubclass(); _pc = _managedType.getProject().loadClass( toPCSubclassName(_managedType.getType())); if (_pc.getSuperclassBC() != _managedType) { _pc.setSuperclass(_managedType); _pc.setAbstract(_managedType.isAbstract()); _pc.declareInterface(DynamicPersistenceCapable.class); } else { _isAlreadySubclassed = true; } } _bcsConfigured = true; } }
/** * Store the value at the top of the stack into the field value specified * by <code>fmd</code>. Before this method is called, the data to load will * be on the top of the stack and the object that the data should be loaded * into will be second in the stack. */ private void addSetManagedValueCode(Code code, FieldMetaData fmd) throws NoSuchMethodException { // if redefining, then we must always reflect (or access the field // directly if accessible), since the redefined methods will always // trigger method calls to StateManager, even from internal direct- // access usage. We could work around this by not redefining, and // just do a subclass approach instead. But this is not a good option, // since it would sacrifice lazy loading and efficient dirty tracking. if (getRedefine() || isFieldAccess(fmd)) { putfield(code, null, fmd.getName(), fmd.getDeclaredType()); } else if (getCreateSubclass()) { // property access, and we're not redefining. invoke the // superclass method to bypass tracking. code.invokespecial().setMethod(_managedType.getType(), getSetterName(fmd), void.class, new Class[] { fmd.getDeclaredType() }); } else { // regular enhancement + property access code.invokevirtual().setMethod(PRE + getSetterName(fmd), void.class, new Class[] { fmd.getDeclaredType() }); } }
/** * Store the value at the top of the stack into the field value specified * by <code>fmd</code>. Before this method is called, the data to load will * be on the top of the stack and the object that the data should be loaded * into will be second in the stack. */ private void addSetManagedValueCode(Code code, FieldMetaData fmd) throws NoSuchMethodException { // if redefining, then we must always reflect (or access the field // directly if accessible), since the redefined methods will always // trigger method calls to StateManager, even from internal direct- // access usage. We could work around this by not redefining, and // just do a subclass approach instead. But this is not a good option, // since it would sacrifice lazy loading and efficient dirty tracking. if (getRedefine() || isFieldAccess(fmd)) { putfield(code, null, fmd.getName(), fmd.getDeclaredType()); } else if (getCreateSubclass()) { // property access, and we're not redefining. invoke the // superclass method to bypass tracking. code.invokespecial().setMethod(_managedType.getType(), getSetterName(fmd), void.class, new Class[] { fmd.getDeclaredType() }); } else { // regular enhancement + property access code.invokevirtual().setMethod(PRE + getSetterName(fmd), void.class, new Class[] { fmd.getDeclaredType() }); } }
/** * Adds a non-static getter that delegates to the super methods, and * performs any necessary field tracking. */ private void addSubclassGetMethod(FieldMetaData fmd) { String methName = "get" + StringUtil.capitalize(fmd.getName()); if (_managedType.getMethods(methName, new Class[0]).length == 0) methName = "is" + StringUtil.capitalize(fmd.getName()); BCMethod getter = _pc.declareMethod(methName, fmd.getDeclaredType(), null); setVisibilityToSuperMethod(getter); getter.makePublic(); Code code = getter.getCode(true); // if we're not already tracking field access via reflection, then we // must make the getter hook in lazy loading before accessing the super // method. if (!getRedefine()) addNotifyAccess(code, fmd); code.aload().setThis(); code.invokespecial().setMethod(_managedType.getType(), methName, fmd.getDeclaredType(), null); code.xreturn().setType(fmd.getDeclaredType()); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Adds a non-static getter that delegates to the super methods, and * performs any necessary field tracking. */ private void addSubclassGetMethod(FieldMetaData fmd) { String methName = "get" + StringUtil.capitalize(fmd.getName()); if (_managedType.getMethods(methName, new Class[0]).length == 0) methName = "is" + StringUtil.capitalize(fmd.getName()); BCMethod getter = _pc.declareMethod(methName, fmd.getDeclaredType(), null); setVisibilityToSuperMethod(getter); getter.makePublic(); Code code = getter.getCode(true); // if we're not already tracking field access via reflection, then we // must make the getter hook in lazy loading before accessing the super // method. if (!getRedefine()) addNotifyAccess(code, fmd); code.aload().setThis(); code.invokespecial().setMethod(_managedType.getType(), methName, fmd.getDeclaredType(), null); code.xreturn().setType(fmd.getDeclaredType()); code.calculateMaxLocals(); code.calculateMaxStack(); }