void (GeneratorAdapter generator) { Label fontNonNull = new Label(); generator.loadArg(3); // font generator.ifNonNull(fontNonNull); generator.push((String)null); generator.returnValue(); generator.mark(fontNonNull); Label nameNonNull = new Label(); generator.loadArg(0); // name generator.ifNonNull(nameNonNull); generator.loadArg(3); // font generator.invokeVirtual(ourFontType, ourGetNameMethod); int nameLocal = generator.newLocal(ourStringType); generator.storeLocal(nameLocal); Label createFont = new Label(); generator.goTo(createFont); generator.mark(nameNonNull); generator.newInstance(ourFontType); generator.dup(); generator.loadArg(0); // name generator.push(Font.PLAIN); generator.push(10); generator.invokeConstructor(ourFontType, ourInitFontMethod); int testFont = generator.newLocal(ourFontType); generator.storeLocal(testFont); Label fontGetNameLabel = new Label(); generator.loadLocal(testFont); generator.push('a'); generator.invokeVirtual(ourFontType, ourCanDisplayMethod); generator.ifZCmp(GeneratorAdapter.EQ, fontGetNameLabel); generator.loadLocal(testFont); generator.push('1'); generator.invokeVirtual(ourFontType, ourCanDisplayMethod); generator.ifZCmp(GeneratorAdapter.EQ, fontGetNameLabel); generator.loadArg(0); // name generator.storeLocal(nameLocal); generator.goTo(createFont); generator.mark(fontGetNameLabel); generator.loadArg(3); // font generator.invokeVirtual(ourFontType, ourGetNameMethod); generator.storeLocal(nameLocal); generator.mark(createFont); generator.newInstance(ourFontType); generator.dup(); generator.loadLocal(nameLocal); Label checkStyle1 = new Label(); Label checkStyle2 = new Label(); generator.loadArg(1); // style generator.ifZCmp(GeneratorAdapter.LT, checkStyle1); generator.loadArg(1); // style generator.goTo(checkStyle2); generator.mark(checkStyle1); generator.loadArg(3); // font generator.invokeVirtual(ourFontType, ourGetStyleMethod); generator.mark(checkStyle2); Label checkSize1 = new Label(); Label checkSize2 = new Label(); generator.loadArg(2); // size generator.ifZCmp(GeneratorAdapter.LT, checkSize1); generator.loadArg(2); // size generator.goTo(checkSize2); generator.mark(checkSize1); generator.loadArg(3); // font generator.invokeVirtual(ourFontType, ourGetSizeMethod); generator.mark(checkSize2); generator.invokeConstructor(ourFontType, ourInitFontMethod); int font = generator.newLocal(ourFontType); generator.storeLocal(font); generator.push("os.name"); generator.push(""); generator.invokeStatic(ourSystemType, ourGetPropertyMethod); generator.getStatic(ourLocaleType, "ENGLISH", ourLocaleType); generator.invokeVirtual(ourStringType, ourToLowerCaseMethod); generator.push("mac"); generator.invokeVirtual(ourStringType, ourStartsWithMethod); int isMac = generator.newLocal(Type.BOOLEAN_TYPE); generator.storeLocal(isMac); Label styleContextLabel = new Label(); generator.loadLocal(isMac); generator.ifZCmp(GeneratorAdapter.EQ, styleContextLabel); generator.newInstance(ourFontType); generator.dup(); generator.loadLocal(font); generator.invokeVirtual(ourFontType, ourGetFamilyMethod); generator.loadLocal(font); generator.invokeVirtual(ourFontType, ourGetStyleMethod); generator.loadLocal(font); generator.invokeVirtual(ourFontType, ourGetSizeMethod); generator.invokeConstructor(ourFontType, ourInitFontMethod); Label resultBlock = new Label(); generator.goTo(resultBlock); generator.mark(styleContextLabel); generator.newInstance(ourStyleContextType); generator.dup(); generator.invokeConstructor(ourStyleContextType, ourInitStyleContextMethod); generator.loadLocal(font); generator.invokeVirtual(ourFontType, ourGetFamilyMethod); generator.loadLocal(font); generator.invokeVirtual(ourFontType, ourGetStyleMethod); generator.loadLocal(font); generator.invokeVirtual(ourFontType, ourGetSizeMethod); generator.invokeVirtual(ourStyleContextType, ourGetFontMethod); generator.mark(resultBlock); int fontWithFallback = generator.newLocal(ourFontType); generator.storeLocal(fontWithFallback); Label newFontResource = new Label(); Label returnBlock = new Label(); generator.loadLocal(fontWithFallback); generator.instanceOf(ourFontUIResource); generator.ifZCmp(GeneratorAdapter.EQ, newFontResource); generator.loadLocal(fontWithFallback); generator.goTo(returnBlock); generator.mark(newFontResource); generator.newInstance(ourFontUIResource); generator.dup(); generator.loadLocal(fontWithFallback); generator.invokeConstructor(ourFontUIResource, ourInitFontUIResourceMethod); generator.mark(returnBlock); generator.returnValue(); generator.endMethod(); }