/** * Return the field assigned in the given method, or null if none. * Package-protected and static for testing. */ static BCField getAssignedField(BCMethod meth) { return findField(meth, (AccessController.doPrivileged( J2DoPrivHelper.newCodeAction())).putfield(), true); }
/** * Return the field assigned in the given method, or null if none. * Package-protected and static for testing. */ static BCField getAssignedField(BCMethod meth) { return findField(meth, (AccessController.doPrivileged( J2DoPrivHelper.newCodeAction())).putfield(), true); }
/** * Return the field assigned in the given method, or null if none. * Package-protected and static for testing. */ static BCField getAssignedField(BCMethod meth) { return findField(meth, (AccessController.doPrivileged( J2DoPrivHelper.newCodeAction())).putfield(), true); }
/** * Return the field assigned in the given method, or null if none. * Package-protected and static for testing. */ static BCField getAssignedField(BCMethod meth) { return findField(meth, (AccessController.doPrivileged( J2DoPrivHelper.newCodeAction())).putfield(), true); }
/** * Return the field assigned in the given method, or null if none. * Package-protected and static for testing. */ static BCField getAssignedField(BCMethod meth) { return findField(meth, ((Code) AccessController.doPrivileged( J2DoPrivHelper.newCodeAction())).putfield(), true); }
/** * Replaced all direct access to managed fields with the appropriate * pcGet/pcSet method. Note that this includes access to fields * owned by PersistenceCapable classes other than this one. */ private void replaceAndValidateFieldAccess() throws NoSuchMethodException { // create template putfield/getfield instructions to search for Code template = AccessController.doPrivileged( J2DoPrivHelper.newCodeAction()); Instruction put = template.putfield(); Instruction get = template.getfield(); Instruction stat = template.invokestatic(); // look through all methods; this is done before any methods are added // so we don't need to worry about excluding synthetic methods. BCMethod[] methods = _managedType.getDeclaredMethods(); Code code; for (int i = 0; i < methods.length; i++) { code = methods[i].getCode(false); // don't modify the methods specified by the auxiliary enhancers if (code != null && !skipEnhance(methods[i])) { replaceAndValidateFieldAccess(code, get, true, stat); replaceAndValidateFieldAccess(code, put, false, stat); } } }
/** * Replaced all direct access to managed fields with the appropriate * pcGet/pcSet method. Note that this includes access to fields * owned by PersistenceCapable classes other than this one. */ private void replaceAndValidateFieldAccess() throws NoSuchMethodException { // create template putfield/getfield instructions to search for Code template = AccessController.doPrivileged( J2DoPrivHelper.newCodeAction()); Instruction put = template.putfield(); Instruction get = template.getfield(); Instruction stat = template.invokestatic(); // look through all methods; this is done before any methods are added // so we don't need to worry about excluding synthetic methods. BCMethod[] methods = _managedType.getDeclaredMethods(); Code code; for (int i = 0; i < methods.length; i++) { code = methods[i].getCode(false); // don't modify the methods specified by the auxiliary enhancers if (code != null && !skipEnhance(methods[i])) { replaceAndValidateFieldAccess(code, get, true, stat); replaceAndValidateFieldAccess(code, put, false, stat); } } }
/** * Replaced all direct access to managed fields with the appropriate * pcGet/pcSet method. Note that this includes access to fields * owned by PersistenceCapable classes other than this one. */ private void replaceAndValidateFieldAccess() throws NoSuchMethodException { // create template putfield/getfield instructions to search for Code template = (Code) AccessController.doPrivileged( J2DoPrivHelper.newCodeAction()); Instruction put = template.putfield(); Instruction get = template.getfield(); Instruction stat = template.invokestatic(); // look through all methods; this is done before any methods are added // so we don't need to worry about excluding synthetic methods. BCMethod[] methods = _managedType.getDeclaredMethods(); Code code; for (int i = 0; i < methods.length; i++) { code = methods[i].getCode(false); // don't modify the methods specified by the auxiliary enhancers if (code != null && !skipEnhance(methods[i])) { replaceAndValidateFieldAccess(code, get, true, stat); replaceAndValidateFieldAccess(code, put, false, stat); } } }
/** * Replaced all direct access to managed fields with the appropriate * pcGet/pcSet method. Note that this includes access to fields * owned by PersistenceCapable classes other than this one. */ private void replaceAndValidateFieldAccess() throws NoSuchMethodException { // create template putfield/getfield instructions to search for Code template = AccessController.doPrivileged( J2DoPrivHelper.newCodeAction()); Instruction put = template.putfield(); Instruction get = template.getfield(); Instruction stat = template.invokestatic(); // look through all methods; this is done before any methods are added // so we don't need to worry about excluding synthetic methods. BCMethod[] methods = _managedType.getDeclaredMethods(); Code code; for (int i = 0; i < methods.length; i++) { code = methods[i].getCode(false); // don't modify the methods specified by the auxiliary enhancers if (code != null && !skipEnhance(methods[i])) { replaceAndValidateFieldAccess(code, get, true, stat); replaceAndValidateFieldAccess(code, put, false, stat); } } }
/** * Replaced all direct access to managed fields with the appropriate * pcGet/pcSet method. Note that this includes access to fields * owned by PersistenceCapable classes other than this one. */ private void replaceAndValidateFieldAccess() throws NoSuchMethodException { // create template putfield/getfield instructions to search for Code template = AccessController.doPrivileged( J2DoPrivHelper.newCodeAction()); Instruction put = template.putfield(); Instruction get = template.getfield(); Instruction stat = template.invokestatic(); // look through all methods; this is done before any methods are added // so we don't need to worry about excluding synthetic methods. BCMethod[] methods = _managedType.getDeclaredMethods(); Code code; for (int i = 0; i < methods.length; i++) { code = methods[i].getCode(false); // don't modify the methods specified by the auxiliary enhancers if (code != null && !skipEnhance(methods[i])) { replaceAndValidateFieldAccess(code, get, true, stat); replaceAndValidateFieldAccess(code, put, false, stat); } } }
/** * Implement initialize. */ private void addInitialize(BCClass bc, int objectCount) { BCMethod meth = bc.declareMethod("initialize", void.class, null); Code code = meth.getCode(true); JumpInstruction ifins = null; if (objectCount > 0) { // if (objects == null) // objects = new Object[objectCount]; code.aload().setThis(); code.getfield().setField("objects", Object[].class); ifins = code.ifnonnull(); code.aload().setThis(); code.constant().setValue(objectCount); code.anewarray().setType(Object.class); code.putfield().setField("objects", Object[].class); } Instruction ins = code.vreturn(); if (ifins != null) ifins.setTarget(ins); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Implement initialize. */ private void addInitialize(BCClass bc, int objectCount) { BCMethod meth = bc.declareMethod("initialize", void.class, null); Code code = meth.getCode(true); JumpInstruction ifins = null; if (objectCount > 0) { // if (objects == null) // objects = new Object[objectCount]; code.aload().setThis(); code.getfield().setField("objects", Object[].class); ifins = code.ifnonnull(); code.aload().setThis(); code.constant().setValue(objectCount); code.anewarray().setType(Object.class); code.putfield().setField("objects", Object[].class); } Instruction ins = code.vreturn(); if (ifins != null) ifins.setTarget(ins); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Implement initialize. */ private void addInitialize(BCClass bc, int objectCount) { BCMethod meth = bc.declareMethod("initialize", void.class, null); Code code = meth.getCode(true); JumpInstruction ifins = null; if (objectCount > 0) { // if (objects == null) // objects = new Object[objectCount]; code.aload().setThis(); code.getfield().setField("objects", Object[].class); ifins = code.ifnonnull(); code.aload().setThis(); code.constant().setValue(objectCount); code.anewarray().setType(Object.class); code.putfield().setField("objects", Object[].class); } Instruction ins = code.vreturn(); if (ifins != null) ifins.setTarget(ins); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Enhance constructor to initialize fields */ private void enhanceConstructor(BCClass bc) { BCMethod cons = bc.getDeclaredMethod("<init>", (String[]) null); Code code = cons.getCode(false); code.afterLast(); code.previous(); // private BitSet loaded = new BitSet(); BCField loaded = addBeanField(bc, "loaded", BitSet.class); loaded.setFinal(true); code.aload().setThis(); code.anew().setType(BitSet.class); code.dup(); code.constant().setValue(bc.getFields().length); code.invokespecial().setMethod(BitSet.class, "<init>", void.class, new Class[]{ int.class }); code.putfield().setField(loaded); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Implement initialize. */ private void addInitialize(BCClass bc, int objectCount) { BCMethod meth = bc.declareMethod("initialize", void.class, null); Code code = meth.getCode(true); JumpInstruction ifins = null; if (objectCount > 0) { // if (objects == null) // objects = new Object[objectCount]; code.aload().setThis(); code.getfield().setField("objects", Object[].class); ifins = code.ifnonnull(); code.aload().setThis(); code.constant().setValue(objectCount); code.anewarray().setType(Object.class); code.putfield().setField("objects", Object[].class); } Instruction ins = code.vreturn(); if (ifins != null) ifins.setTarget(ins); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Enhance constructor to initialize fields */ private void enhanceConstructor(BCClass bc) { BCMethod cons = bc.getDeclaredMethod("<init>", (String[]) null); Code code = cons.getCode(false); code.afterLast(); code.previous(); // private BitSet loaded = new BitSet(); BCField loaded = addBeanField(bc, "loaded", BitSet.class); loaded.setFinal(true); code.aload().setThis(); code.anew().setType(BitSet.class); code.dup(); code.constant().setValue(bc.getFields().length); code.invokespecial().setMethod(BitSet.class, "<init>", void.class, new Class[]{ int.class }); code.putfield().setField(loaded); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Enhance constructor to initialize fields */ private void enhanceConstructor(BCClass bc) { BCMethod cons = bc.getDeclaredMethod("<init>", (String[]) null); Code code = cons.getCode(false); code.afterLast(); code.previous(); // private BitSet loaded = new BitSet(); BCField loaded = addBeanField(bc, "loaded", BitSet.class); loaded.setFinal(true); code.aload().setThis(); code.anew().setType(BitSet.class); code.dup(); code.constant().setValue(bc.getFields().length); code.invokespecial().setMethod(BitSet.class, "<init>", void.class, new Class[]{ int.class }); code.putfield().setField(loaded); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Enhance constructor to initialize fields */ private void enhanceConstructor(BCClass bc) { BCMethod cons = bc.getDeclaredMethod("<init>", (String[]) null); Code code = cons.getCode(false); code.afterLast(); code.previous(); // private BitSet loaded = new BitSet(); BCField loaded = addBeanField(bc, "loaded", BitSet.class); loaded.setFinal(true); code.aload().setThis(); code.anew().setType(BitSet.class); code.dup(); code.constant().setValue(bc.getFields().length); code.invokespecial().setMethod(BitSet.class, "<init>", void.class, new Class[]{ int.class }); code.putfield().setField(loaded); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Implement initialize. */ private void addInitialize(BCClass bc, int objectCount) { BCMethod meth = bc.declareMethod("initialize", void.class, null); Code code = meth.getCode(true); JumpInstruction ifins = null; if (objectCount > 0) { // if (objects == null) // objects = new Object[objectCount]; code.aload().setThis(); code.getfield().setField("objects", Object[].class); ifins = code.ifnonnull(); code.aload().setThis(); code.constant().setValue(objectCount); code.anewarray().setType(Object.class); code.putfield().setField("objects", Object[].class); } Instruction ins = code.vreturn(); if (ifins != null) ifins.setTarget(ins); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Enhance constructor to initialize fields */ private void enhanceConstructor(BCClass bc) { BCMethod cons = bc.getDeclaredMethod("<init>", (String[]) null); Code code = cons.getCode(false); code.afterLast(); code.previous(); // private BitSet loaded = new BitSet(); BCField loaded = addBeanField(bc, "loaded", BitSet.class); loaded.setFinal(true); code.aload().setThis(); code.anew().setType(BitSet.class); code.dup(); code.constant().setValue(bc.getFields().length); code.invokespecial().setMethod(BitSet.class, "<init>", void.class, new Class[]{ int.class }); code.putfield().setField(loaded); code.calculateMaxStack(); code.calculateMaxLocals(); }