private void addNotifyAccess(Code code, FieldMetaData fmd) { // PCHelper.accessingField(this, <absolute-index>); code.aload().setThis(); code.constant().setValue(fmd.getIndex()); code.invokestatic().setMethod(RedefinitionHelper.class, "accessingField", void.class, new Class[] { Object.class, int.class }); }
private void addNotifyAccess(Code code, FieldMetaData fmd) { // PCHelper.accessingField(this, <absolute-index>); code.aload().setThis(); code.constant().setValue(fmd.getIndex()); code.invokestatic().setMethod(RedefinitionHelper.class, "accessingField", void.class, new Class[] { Object.class, int.class }); }
/** * Proxy the given method with one that overrides it by calling into the * given helper. */ private void proxyOverrideMethod(BCClass bc, Method meth, Method helper, Class[] params) { BCMethod m = bc.declareMethod(meth.getName(), meth.getReturnType(), meth.getParameterTypes()); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); for (int i = 1; i < params.length; i++) code.xload().setParam(i - 1).setType(params[i]); code.invokestatic().setMethod(helper); code.xreturn().setType(meth.getReturnType()); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Proxy the given method with one that overrides it by calling into the * given helper. */ private void proxyOverrideMethod(BCClass bc, Method meth, Method helper, Class[] params) { BCMethod m = bc.declareMethod(meth.getName(), meth.getReturnType(), meth.getParameterTypes()); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); for (int i = 1; i < params.length; i++) code.xload().setParam(i - 1).setType(params[i]); code.invokestatic().setMethod(helper); code.xreturn().setType(meth.getReturnType()); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Proxy the given method with one that overrides it by calling into the * given helper. */ private void proxyOverrideMethod(BCClass bc, Method meth, Method helper, Class[] params) { BCMethod m = bc.declareMethod(meth.getName(), meth.getReturnType(), meth.getParameterTypes()); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); for (int i = 1; i < params.length; i++) code.xload().setParam(i - 1).setType(params[i]); code.invokestatic().setMethod(helper); code.xreturn().setType(meth.getReturnType()); code.calculateMaxStack(); code.calculateMaxLocals(); }
private void addNotifyAccess(Code code, FieldMetaData fmd) { // PCHelper.accessingField(this, <absolute-index>); code.aload().setThis(); code.constant().setValue(fmd.getIndex()); code.invokestatic().setMethod(RedefinitionHelper.class, "accessingField", void.class, new Class[] { Object.class, int.class }); }
/** * Proxy the given method with one that overrides it by calling into the * given helper. */ private void proxyOverrideMethod(BCClass bc, Method meth, Method helper, Class[] params) { BCMethod m = bc.declareMethod(meth.getName(), meth.getReturnType(), meth.getParameterTypes()); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); for (int i = 1; i < params.length; i++) code.xload().setParam(i - 1).setType(params[i]); code.invokestatic().setMethod(helper); code.xreturn().setType(meth.getReturnType()); code.calculateMaxStack(); code.calculateMaxLocals(); }
private void addNotifyAccess(Code code, FieldMetaData fmd) { // PCHelper.accessingField(this, <absolute-index>); code.aload().setThis(); code.constant().setValue(fmd.getIndex()); code.invokestatic().setMethod(RedefinitionHelper.class, "accessingField", void.class, new Class[] { Object.class, int.class }); }
/** * Proxy the given method with one that overrides it by calling into the * given helper. */ private void proxyOverrideMethod(BCClass bc, Method meth, Method helper, Class[] params) { BCMethod m = bc.declareMethod(meth.getName(), meth.getReturnType(), meth.getParameterTypes()); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); for (int i = 1; i < params.length; i++) code.xload().setParam(i - 1).setType(params[i]); code.invokestatic().setMethod(helper); code.xreturn().setType(meth.getReturnType()); code.calculateMaxStack(); code.calculateMaxLocals(); }
private void addNotifyAccess(Code code, FieldMetaData fmd) { // PCHelper.accessingField(this, <absolute-index>); code.aload().setThis(); code.constant().setValue(fmd.getIndex()); code.invokestatic().setMethod(RedefinitionHelper.class, "accessingField", void.class, new Class[] { Object.class, int.class }); }
/** * Proxy the given setter method to dirty the proxy owner. */ private void proxySetter(BCClass bc, Class type, Method meth) { Class[] params = meth.getParameterTypes(); Class ret = meth.getReturnType(); BCMethod m = bc.declareMethod(meth.getName(), ret, params); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(true); code.invokestatic().setMethod(Proxies.class, "dirty", void.class, new Class[] { Proxy.class, boolean.class }); code.aload().setThis(); for (int i = 0; i < params.length; i++) code.xload().setParam(i).setType(params[i]); code.invokespecial().setMethod(type, meth.getName(), ret, params); code.xreturn().setType(ret); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Proxy the given setter method to dirty the proxy owner. */ private void proxySetter(BCClass bc, Class type, Method meth) { Class[] params = meth.getParameterTypes(); Class ret = meth.getReturnType(); BCMethod m = bc.declareMethod(meth.getName(), ret, params); m.makePublic(); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(true); code.invokestatic().setMethod(Proxies.class, "dirty", void.class, new Class[] { Proxy.class, boolean.class }); code.aload().setThis(); for (int i = 0; i < params.length; i++) code.xload().setParam(i).setType(params[i]); code.invokespecial().setMethod(type, meth.getName(), ret, params); code.xreturn().setType(ret); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Add a writeReplace implementation that serializes to a non-proxy type * unless detached and this is a build-time generated class. */ private void addWriteReplaceMethod(BCClass bc, boolean runtime) { BCMethod m = bc.declareMethod("writeReplace", Object.class, null); m.makeProtected(); m.getExceptions(true).addException(ObjectStreamException.class); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(!runtime); code.invokestatic().setMethod(Proxies.class, "writeReplace", Object.class, new Class[] { Proxy.class, boolean.class }); code.areturn(); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Add a writeReplace implementation that serializes to a non-proxy type * unless detached and this is a build-time generated class. */ private void addWriteReplaceMethod(BCClass bc, boolean runtime) { BCMethod m = bc.declareMethod("writeReplace", Object.class, null); m.makeProtected(); m.getExceptions(true).addException(ObjectStreamException.class); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(!runtime); code.invokestatic().setMethod(Proxies.class, "writeReplace", Object.class, new Class[] { Proxy.class, boolean.class }); code.areturn(); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Add a writeReplace implementation that serializes to a non-proxy type * unless detached and this is a build-time generated class. */ private void addWriteReplaceMethod(BCClass bc, boolean runtime) { BCMethod m = bc.declareMethod("writeReplace", Object.class, null); m.makeProtected(); m.getExceptions(true).addException(ObjectStreamException.class); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(!runtime); code.invokestatic().setMethod(Proxies.class, "writeReplace", Object.class, new Class[] { Proxy.class, boolean.class }); code.areturn(); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Add a writeReplace implementation that serializes to a non-proxy type * unless detached and this is a build-time generated class. */ private void addWriteReplaceMethod(BCClass bc, boolean runtime) { BCMethod m = bc.declareMethod("writeReplace", Object.class, null); m.makeProtected(); m.getExceptions(true).addException(ObjectStreamException.class); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(!runtime); code.invokestatic().setMethod(Proxies.class, "writeReplace", Object.class, new Class[] { Proxy.class, boolean.class }); code.areturn(); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Add a writeReplace implementation that serializes to a non-proxy type * unless detached and this is a build-time generated class. */ private void addWriteReplaceMethod(BCClass bc, boolean runtime) { BCMethod m = bc.declareMethod("writeReplace", Object.class, null); m.makeProtected(); m.getExceptions(true).addException(ObjectStreamException.class); Code code = m.getCode(true); code.aload().setThis(); code.constant().setValue(!runtime); code.invokestatic().setMethod(Proxies.class, "writeReplace", Object.class, new Class[] { Proxy.class, boolean.class }); code.areturn(); code.calculateMaxLocals(); code.calculateMaxStack(); }
/** * Adds fields and methods as necessary to load a class constant of * an object type. */ private void setObject(String name) { BCField field = addClassField(name); BCMethod method = addClassLoadMethod(); // copied from the way jikes loads classes _code.getstatic().setField(field); JumpInstruction ifnull = _code.ifnull(); _code.getstatic().setField(field); JumpInstruction go2 = _code.go2(); ifnull.setTarget(_code.constant().setValue(name)); _code.invokestatic().setMethod(method); _code.dup(); _code.putstatic().setField(field); go2.setTarget(_code.nop()); }
private void addEnhancement(BCClass bcc, ClassMetaData cmd) { Log log = cmd.getRepository().getConfiguration().getLog(OpenJPAConfiguration.LOG_RUNTIME); FetchStatsCollector.setlogger(log); for (BCMethod meth : bcc.getMethods()) { String methodName = meth.getName(); FieldMetaData fmd = getFieldName(methodName, cmd); if (fmd != null && needsTracking(fmd, methodName, cmd)) { String fqn = bcc.getName() + "." + fmd.getName(); FetchStatsCollector.registerField(fqn); FetchStatsCollector.registerEntity(cmd); Code code = meth.getCode(false); code.constant().setValue(fqn); code.invokestatic().setMethod(FetchStatsCollector.class, "hit", void.class, new Class[] { String.class }); } } }
/** * Adds fields and methods as necessary to load a class constant of * an object type. */ private void setObject(String name) { BCField field = addClassField(name); BCMethod method = addClassLoadMethod(); // copied from the way jikes loads classes _code.getstatic().setField(field); JumpInstruction ifnull = _code.ifnull(); _code.getstatic().setField(field); JumpInstruction go2 = _code.go2(); ifnull.setTarget(_code.constant().setValue(name)); _code.invokestatic().setMethod(method); _code.dup(); _code.putstatic().setField(field); go2.setTarget(_code.nop()); }