/** * Create the generated getter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createGetMethod(FieldMetaData fmd) { BCMethod getter; if (isFieldAccess(fmd)) { // static <fieldtype> pcGet<field> (XXX inst) BCField field = _pc.getDeclaredField(fmd.getName()); getter = _pc.declareMethod(PRE + "Get" + fmd.getName(), fmd. getDeclaredType().getName(), new String[]{ _pc.getName() }); getter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); getter.setStatic(true); getter.setFinal(true); return getter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method Method meth = (Method) fmd.getBackingMember(); getter = _pc.getDeclaredMethod(meth.getName(), meth.getParameterTypes()); BCMethod newgetter = _pc.declareMethod(PRE + meth.getName(), meth.getReturnType(), meth.getParameterTypes()); newgetter.setAccessFlags(getter.getAccessFlags()); newgetter.makeProtected(); transferCodeAttributes(getter, newgetter); return getter; }
/** * Write unmanaged fields to the stream (pcWriteUnmanaged). */ private void addWriteUnmanaged(Collection unmgd, boolean parentDetachable) throws NoSuchMethodException { Class[] outargs = new Class[]{ ObjectOutput.class }; BCMethod meth = _pc.declareMethod(PRE + "WriteUnmanaged", void.class, outargs); meth.makeProtected(); Exceptions exceps = meth.getExceptions(true); exceps.addException(IOException.class); Code code = meth.getCode(true); // super.writeUnmanaged (out); if (parentDetachable) { loadManagedInstance(code, false); code.aload().setParam(0); code.invokespecial().setMethod(getType(_meta. getPCSuperclassMetaData()), PRE + "WriteUnmanaged", void.class, outargs); } // write declared unmanaged serializable fields BCField field; for (Iterator itr = unmgd.iterator(); itr.hasNext();) { field = (BCField) itr.next(); writeExternal(code, field.getName(), field.getType(), null); } code.vreturn(); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Write unmanaged fields to the stream (pcWriteUnmanaged). */ private void addWriteUnmanaged(Collection unmgd, boolean parentDetachable) throws NoSuchMethodException { Class[] outargs = new Class[]{ ObjectOutput.class }; BCMethod meth = _pc.declareMethod(PRE + "WriteUnmanaged", void.class, outargs); meth.makeProtected(); Exceptions exceps = meth.getExceptions(true); exceps.addException(IOException.class); Code code = meth.getCode(true); // super.writeUnmanaged (out); if (parentDetachable) { loadManagedInstance(code, false); code.aload().setParam(0); code.invokespecial().setMethod(getType(_meta. getPCSuperclassMetaData()), PRE + "WriteUnmanaged", void.class, outargs); } // write declared unmanaged serializable fields BCField field; for (Iterator itr = unmgd.iterator(); itr.hasNext();) { field = (BCField) itr.next(); writeExternal(code, field.getName(), field.getType(), null); } code.vreturn(); code.calculateMaxStack(); code.calculateMaxLocals(); }
/** * Write unmanaged fields to the stream (pcWriteUnmanaged). */ private void addWriteUnmanaged(Collection unmgd, boolean parentDetachable) throws NoSuchMethodException { Class[] outargs = new Class[]{ ObjectOutput.class }; BCMethod meth = _pc.declareMethod(PRE + "WriteUnmanaged", void.class, outargs); meth.makeProtected(); Exceptions exceps = meth.getExceptions(true); exceps.addException(IOException.class); Code code = meth.getCode(true); // super.writeUnmanaged (out); if (parentDetachable) { loadManagedInstance(code, false); code.aload().setParam(0); code.invokespecial().setMethod(getType(_meta. getPCSuperclassMetaData()), PRE + "WriteUnmanaged", void.class, outargs); } // write declared unmanaged serializable fields BCField field; for (Iterator itr = unmgd.iterator(); itr.hasNext();) { field = (BCField) itr.next(); writeExternal(code, field.getName(), field.getType(), null); } code.vreturn(); code.calculateMaxStack(); code.calculateMaxLocals(); }
int.class, null); method.setStatic(true); method.makeProtected(); Code code = method.getCode(true);
/** * 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(); }
private boolean setVisibilityToSuperMethod(BCMethod method) { BCMethod[] methods = _managedType.getMethods(method.getName(), method.getParamTypes()); if (methods.length == 0) throw new UserException(_loc.get("no-accessor", _managedType.getName(), method.getName())); BCMethod superMeth = methods[0]; if (superMeth.isPrivate()) { method.makePrivate(); return true; } else if (superMeth.isPackage()) { method.makePackage(); return true; } else if (superMeth.isProtected()) { method.makeProtected(); return true; } else if (superMeth.isPublic()) { method.makePublic(); return true; } return false; }
private boolean setVisibilityToSuperMethod(BCMethod method) { BCMethod[] methods = _managedType.getMethods(method.getName(), method.getParamTypes()); if (methods.length == 0) throw new UserException(_loc.get("no-accessor", _managedType.getName(), method.getName())); BCMethod superMeth = methods[0]; if (superMeth.isPrivate()) { method.makePrivate(); return true; } else if (superMeth.isPackage()) { method.makePackage(); return true; } else if (superMeth.isProtected()) { method.makeProtected(); return true; } else if (superMeth.isPublic()) { method.makePublic(); return true; } return false; }
private boolean setVisibilityToSuperMethod(BCMethod method) { BCMethod[] methods = _managedType.getMethods(method.getName(), method.getParamTypes()); if (methods.length == 0) throw new UserException(_loc.get("no-accessor", _managedType.getName(), method.getName())); BCMethod superMeth = methods[0]; if (superMeth.isPrivate()) { method.makePrivate(); return true; } else if (superMeth.isPackage()) { method.makePackage(); return true; } else if (superMeth.isProtected()) { method.makeProtected(); return true; } else if (superMeth.isPublic()) { method.makePublic(); return true; } return false; }
private boolean setVisibilityToSuperMethod(BCMethod method) { BCMethod[] methods = _managedType.getMethods(method.getName(), method.getParamTypes()); if (methods.length == 0) throw new UserException(_loc.get("no-accessor", _managedType.getName(), method.getName())); BCMethod superMeth = methods[0]; if (superMeth.isPrivate()) { method.makePrivate(); return true; } else if (superMeth.isPackage()) { method.makePackage(); return true; } else if (superMeth.isProtected()) { method.makeProtected(); return true; } else if (superMeth.isPublic()) { method.makePublic(); return true; } return false; }
private boolean setVisibilityToSuperMethod(BCMethod method) { BCMethod[] methods = _managedType.getMethods(method.getName(), method.getParamTypes()); if (methods.length == 0) throw new UserException(_loc.get("no-accessor", _managedType.getName(), method.getName())); BCMethod superMeth = methods[0]; if (superMeth.isPrivate()) { method.makePrivate(); return true; } else if (superMeth.isPackage()) { method.makePackage(); return true; } else if (superMeth.isProtected()) { method.makeProtected(); return true; } else if (superMeth.isPublic()) { method.makePublic(); return true; } return false; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (_meta.getAccessType() == ClassMetaData.ACCESS_FIELD) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }