/** * @param b true to set static, false otherwise */ public Modifiers toStatic(boolean b) { return convert(toStatic(mBitmask, b)); }
/** * Add a static initializer to this class. */ public MethodInfo addInitializer() { MethodDesc md = MethodDesc.forArguments(null, null); Modifiers af = Modifiers.NONE.toStatic(true); MethodInfo mi = new MethodInfo(this, af, "<clinit>", md); mMethods.add(mi); return mi; }
modifiers = modifiers.toStatic(true); } else if ("synchronized".equals(ident)) { modifiers = modifiers.toSynchronized(true);
Modifiers modifiers = inner.getModifiers().toPrivate(true).toStatic(true); inner.setModifiers(modifiers); inner.mInnerClassName = innerClassName;
.toStatic(innerFlags.isStatic()) .toPrivate(innerFlags.isPrivate()) .toProtected(innerFlags.isProtected())
/** * @param b true to set static, false otherwise */ public Modifiers toStatic(boolean b) { return convert(toStatic(mBitmask, b)); }
/** * Add a static initializer to this class. */ public MethodInfo addInitializer() { MethodDesc md = MethodDesc.forArguments(null, null); Modifiers af = Modifiers.NONE.toStatic(true); MethodInfo mi = new MethodInfo(this, af, "<clinit>", md); mMethods.add(mi); return mi; }
} else if (modifiers.isStatic()) { print("PUBLIC_STATIC"); modifiers = modifiers.toStatic(false); } else { print("PUBLIC");
modifiers = modifiers.toStatic(true); } else if ("synchronized".equals(ident)) { modifiers = modifiers.toSynchronized(true);
final TypeDesc filterType = TypeDesc.forClass(Filter.class); mClassFile.addField(Modifiers.PRIVATE.toStatic(true), fieldName, filterType); mSubFilterInitBuilder = new CodeBuilder (mClassFile.addMethod (Modifiers.PUBLIC.toStatic(true), SUB_FILTER_INIT_METHOD, null, new TypeDesc[] {filterArrayType}));
final TypeDesc filterType = TypeDesc.forClass(Filter.class); mClassFile.addField(Modifiers.PRIVATE.toStatic(true), fieldName, filterType); mSubFilterInitBuilder = new CodeBuilder (mClassFile.addMethod (Modifiers.PUBLIC.toStatic(true), SUB_FILTER_INIT_METHOD, null, new TypeDesc[] {filterArrayType}));
private String addStaticComparatorField(TypeDesc type) { if (mComparatorFields == null) { mComparatorFields = new IdentityHashMap<TypeDesc, String>(); } String fieldName = mComparatorFields.get(type); if (fieldName != null) { return fieldName; } fieldName = COMPARATOR_FIELD_PREFIX + mComparatorFields.size(); TypeDesc comparatorType = TypeDesc.forClass(Comparator.class); mClassFile.addField(Modifiers.PRIVATE.toStatic(true).toFinal(true), fieldName, comparatorType); if (mStaticInitBuilder == null) { mStaticInitBuilder = new CodeBuilder(mClassFile.addInitializer()); } mStaticInitBuilder.loadConstant(type); mStaticInitBuilder.loadConstant(true); mStaticInitBuilder.invokeStatic (TypeDesc.forClass(Comparators.class), "arrayComparator", comparatorType, new TypeDesc[] {TypeDesc.forClass(Class.class), BOOLEAN}); mStaticInitBuilder.storeStaticField(fieldName, comparatorType); mComparatorFields.put(type, fieldName); return fieldName; }
private String addStaticComparatorField(TypeDesc type) { if (mComparatorFields == null) { mComparatorFields = new IdentityHashMap<TypeDesc, String>(); } String fieldName = mComparatorFields.get(type); if (fieldName != null) { return fieldName; } fieldName = COMPARATOR_FIELD_PREFIX + mComparatorFields.size(); TypeDesc comparatorType = TypeDesc.forClass(Comparator.class); mClassFile.addField(Modifiers.PRIVATE.toStatic(true).toFinal(true), fieldName, comparatorType); if (mStaticInitBuilder == null) { mStaticInitBuilder = new CodeBuilder(mClassFile.addInitializer()); } mStaticInitBuilder.loadConstant(type); mStaticInitBuilder.loadConstant(true); mStaticInitBuilder.invokeStatic (TypeDesc.forClass(Comparators.class), "arrayComparator", comparatorType, new TypeDesc[] {TypeDesc.forClass(Class.class), BOOLEAN}); mStaticInitBuilder.storeStaticField(fieldName, comparatorType); mComparatorFields.put(type, fieldName); return fieldName; }
cf.addField(Modifiers.PRIVATE.toStatic(true).toFinal(true), "serialVersionUID", TypeDesc.LONG).setConstantValue(serialVersionUID);
Modifiers modifiers = inner.getModifiers().toPrivate(true).toStatic(true); inner.setModifiers(modifiers); inner.mInnerClassName = innerClassName;
.toStatic(innerFlags.isStatic()) .toPrivate(innerFlags.isPrivate()) .toProtected(innerFlags.isProtected())
String name = "field$" + i; names[i] = name; cf.addField(Modifiers.PRIVATE.toStatic(true).toFinal(true), name, types[i]);
/** * Generates method which passes exception to uncaught exception handler. */ private void defineUncaughtExceptionHandler() { MethodInfo mi = mClassFile.addMethod (Modifiers.PRIVATE.toStatic(true), UNCAUGHT_METHOD_NAME, null, new TypeDesc[] {TypeDesc.forClass(Throwable.class)}); CodeBuilder b = new CodeBuilder(mi); // Thread t = Thread.currentThread(); // t.getUncaughtExceptionHandler().uncaughtException(t, e); TypeDesc threadType = TypeDesc.forClass(Thread.class); b.invokeStatic(Thread.class.getName(), "currentThread", threadType, null); LocalVariable threadVar = b.createLocalVariable(null, threadType); b.storeLocal(threadVar); b.loadLocal(threadVar); TypeDesc handlerType = TypeDesc.forClass(Thread.UncaughtExceptionHandler.class); b.invokeVirtual(threadType, "getUncaughtExceptionHandler", handlerType, null); b.loadLocal(threadVar); b.loadLocal(b.getParameter(0)); b.invokeInterface(handlerType, "uncaughtException", null, new TypeDesc[] {threadType, TypeDesc.forClass(Throwable.class)}); b.returnVoid(); }
/** * Generates method which passes exception to uncaught exception handler. */ private void defineUncaughtExceptionHandler() { MethodInfo mi = mClassFile.addMethod (Modifiers.PRIVATE.toStatic(true), UNCAUGHT_METHOD_NAME, null, new TypeDesc[] {TypeDesc.forClass(Throwable.class)}); CodeBuilder b = new CodeBuilder(mi); // Thread t = Thread.currentThread(); // t.getUncaughtExceptionHandler().uncaughtException(t, e); TypeDesc threadType = TypeDesc.forClass(Thread.class); b.invokeStatic(Thread.class.getName(), "currentThread", threadType, null); LocalVariable threadVar = b.createLocalVariable(null, threadType); b.storeLocal(threadVar); b.loadLocal(threadVar); TypeDesc handlerType = TypeDesc.forClass(Thread.UncaughtExceptionHandler.class); b.invokeVirtual(threadType, "getUncaughtExceptionHandler", handlerType, null); b.loadLocal(threadVar); b.loadLocal(b.getParameter(0)); b.invokeInterface(handlerType, "uncaughtException", null, new TypeDesc[] {threadType, TypeDesc.forClass(Throwable.class)}); b.returnVoid(); }
} else if (modifiers.isStatic()) { print("PUBLIC_STATIC"); modifiers = modifiers.toStatic(false); } else { print("PUBLIC");