diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java index 519c397da..c36764ada 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/io/TPrintStream.java @@ -166,6 +166,11 @@ public class TPrintStream extends TFilterOutputStream { printSB(); } + public void println(double d) { + sb.append(d).append('\n'); + printSB(); + } + public void print(TString s) { sb.append(s); printSB(); diff --git a/teavm-extras-slf4j/src/main/java/org/teavm/extras/slf4j/LoggerFactoryTransformer.java b/teavm-extras-slf4j/src/main/java/org/teavm/extras/slf4j/LoggerFactoryTransformer.java index 14bd34520..96b45dabf 100644 --- a/teavm-extras-slf4j/src/main/java/org/teavm/extras/slf4j/LoggerFactoryTransformer.java +++ b/teavm-extras-slf4j/src/main/java/org/teavm/extras/slf4j/LoggerFactoryTransformer.java @@ -17,6 +17,7 @@ package org.teavm.extras.slf4j; import org.slf4j.ILoggerFactory; import org.slf4j.LoggerFactory; +import org.slf4j.helpers.SubstituteLoggerFactory; import org.teavm.diagnostics.Diagnostics; import org.teavm.model.*; import org.teavm.model.instructions.*; @@ -34,6 +35,7 @@ public class LoggerFactoryTransformer implements ClassHolderTransformer { addCacheField(cls); modifyClinit(cls); replaceGetFactory(cls); + cls.removeField(cls.getField("TEMP_FACTORY")); } private void addCacheField(ClassHolder cls) { @@ -61,6 +63,25 @@ public class LoggerFactoryTransformer implements ClassHolderTransformer { put.setValue(factoryVar); put.setField(new FieldReference(LoggerFactory.class.getName(), "loggerFactoryCache")); clinitBlock.getInstructions().add(2, put); + + Program program = clinit.getProgram(); + for (int i = 0; i < program.basicBlockCount(); ++i) { + BasicBlock block = program.basicBlockAt(i); + for (int j = 0; j < block.getInstructions().size(); ++j) { + Instruction insn = block.getInstructions().get(j); + if (insn instanceof InvokeInstruction) { + InvokeInstruction invoke = (InvokeInstruction)insn; + if (invoke.getMethod().getClassName().equals(SubstituteLoggerFactory.class.getName())) { + block.getInstructions().set(j, new EmptyInstruction()); + } + } else if (insn instanceof PutFieldInstruction) { + PutFieldInstruction putField = (PutFieldInstruction)insn; + if (putField.getField().getFieldName().equals("TEMP_FACTORY")) { + block.getInstructions().set(j, new EmptyInstruction()); + } + } + } + } } private void replaceGetFactory(ClassHolder cls) {