From 4bb6440322e4e248df883db1904a81e2c71c1d50 Mon Sep 17 00:00:00 2001 From: Esko Luontola Date: Wed, 11 Jan 2017 02:24:29 +0200 Subject: [PATCH] Use a logging framework --- ...Maven__com_esotericsoftware_minlog_1_3.xml | 13 +++++++++++++ parent/pom.xml | 6 ++++++ .../retrolambda-maven-plugin.iml | 1 + retrolambda/pom.xml | 15 +++++++++++++++ retrolambda/retrolambda.iml | 1 + .../java/net/orfjackal/retrolambda/Main.java | 9 +++++---- .../orfjackal/retrolambda/Retrolambda.java | 19 ++++++++++--------- .../WarnAboutDefaultAndStaticMethods.java | 5 +++-- .../lambdas/BackportLambdaInvocations.java | 7 +++---- .../retrolambda/lambdas/LambdaClassSaver.java | 5 +++-- 10 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 .idea/libraries/Maven__com_esotericsoftware_minlog_1_3.xml diff --git a/.idea/libraries/Maven__com_esotericsoftware_minlog_1_3.xml b/.idea/libraries/Maven__com_esotericsoftware_minlog_1_3.xml new file mode 100644 index 00000000..731c465d --- /dev/null +++ b/.idea/libraries/Maven__com_esotericsoftware_minlog_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/parent/pom.xml b/parent/pom.xml index 2455b778..9a55b40c 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -131,6 +131,12 @@ 2.6 + + com.esotericsoftware + minlog + 1.3 + + diff --git a/retrolambda-maven-plugin/retrolambda-maven-plugin.iml b/retrolambda-maven-plugin/retrolambda-maven-plugin.iml index 2fc7ee75..99b0c8b8 100644 --- a/retrolambda-maven-plugin/retrolambda-maven-plugin.iml +++ b/retrolambda-maven-plugin/retrolambda-maven-plugin.iml @@ -22,6 +22,7 @@ + diff --git a/retrolambda/pom.xml b/retrolambda/pom.xml index 3e3bcdd9..54cb6e17 100644 --- a/retrolambda/pom.xml +++ b/retrolambda/pom.xml @@ -25,6 +25,11 @@ guava + + com.esotericsoftware + minlog + + @@ -99,6 +104,10 @@ com.google net.orfjackal.retrolambda.google + + com.esotericsoftware.minlog + net.orfjackal.retrolambda.minlog + @@ -115,6 +124,12 @@ META-INF/** + + com.esotericsoftware:minlog + + META-INF/** + + diff --git a/retrolambda/retrolambda.iml b/retrolambda/retrolambda.iml index f9973a8d..cf800908 100644 --- a/retrolambda/retrolambda.iml +++ b/retrolambda/retrolambda.iml @@ -12,6 +12,7 @@ + diff --git a/retrolambda/src/main/java/net/orfjackal/retrolambda/Main.java b/retrolambda/src/main/java/net/orfjackal/retrolambda/Main.java index 5b6ed9c9..b3fa8621 100644 --- a/retrolambda/src/main/java/net/orfjackal/retrolambda/Main.java +++ b/retrolambda/src/main/java/net/orfjackal/retrolambda/Main.java @@ -1,9 +1,11 @@ -// Copyright © 2013-2015 Esko Luontola +// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors // This software is released under the Apache License 2.0. // The license text is at http://www.apache.org/licenses/LICENSE-2.0 package net.orfjackal.retrolambda; +import com.esotericsoftware.minlog.Log; + import java.io.*; import java.util.Properties; @@ -13,7 +15,7 @@ public static void main(String[] args) { System.out.println("Retrolambda " + getVersion()); if (!isRunningJava8()) { - System.out.println("Error! Not running under Java 8"); + Log.error("Not running under Java 8"); System.exit(1); } @@ -25,8 +27,7 @@ public static void main(String[] args) { try { Retrolambda.run(config); } catch (Throwable t) { - System.out.println("Error! Failed to run Retrolambda"); - t.printStackTrace(System.out); + Log.error("Failed to run Retrolambda", t); System.exit(1); } } diff --git a/retrolambda/src/main/java/net/orfjackal/retrolambda/Retrolambda.java b/retrolambda/src/main/java/net/orfjackal/retrolambda/Retrolambda.java index e03da2b8..07eb767e 100644 --- a/retrolambda/src/main/java/net/orfjackal/retrolambda/Retrolambda.java +++ b/retrolambda/src/main/java/net/orfjackal/retrolambda/Retrolambda.java @@ -1,9 +1,10 @@ -// Copyright © 2013-2015 Esko Luontola +// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors // This software is released under the Apache License 2.0. // The license text is at http://www.apache.org/licenses/LICENSE-2.0 package net.orfjackal.retrolambda; +import com.esotericsoftware.minlog.Log; import net.orfjackal.retrolambda.files.*; import net.orfjackal.retrolambda.interfaces.*; import net.orfjackal.retrolambda.lambdas.*; @@ -23,16 +24,16 @@ public static void run(Config config) throws Throwable { Path outputDir = config.getOutputDir(); List classpath = config.getClasspath(); List includedFiles = config.getIncludedFiles(); - System.out.println("Bytecode version: " + bytecodeVersion + " (" + Bytecode.getJavaVersion(bytecodeVersion) + ")"); - System.out.println("Default methods: " + defaultMethodsEnabled); - System.out.println("Input directory: " + inputDir); - System.out.println("Output directory: " + outputDir); - System.out.println("Classpath: " + classpath); - System.out.println("Included files: " + (includedFiles != null ? includedFiles.size() : "all")); - System.out.println("Agent enabled: " + PreMain.isAgentLoaded()); + Log.info("Bytecode version: " + bytecodeVersion + " (" + Bytecode.getJavaVersion(bytecodeVersion) + ")"); + Log.info("Default methods: " + defaultMethodsEnabled); + Log.info("Input directory: " + inputDir); + Log.info("Output directory: " + outputDir); + Log.info("Classpath: " + classpath); + Log.info("Included files: " + (includedFiles != null ? includedFiles.size() : "all")); + Log.info("Agent enabled: " + PreMain.isAgentLoaded()); if (!Files.isDirectory(inputDir)) { - System.out.println("Nothing to do; not a directory: " + inputDir); + Log.info("Nothing to do; not a directory: " + inputDir); return; } diff --git a/retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/WarnAboutDefaultAndStaticMethods.java b/retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/WarnAboutDefaultAndStaticMethods.java index c7221648..ab976ef5 100644 --- a/retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/WarnAboutDefaultAndStaticMethods.java +++ b/retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces/WarnAboutDefaultAndStaticMethods.java @@ -1,9 +1,10 @@ -// Copyright © 2013-2015 Esko Luontola +// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors // This software is released under the Apache License 2.0. // The license text is at http://www.apache.org/licenses/LICENSE-2.0 package net.orfjackal.retrolambda.interfaces; +import com.esotericsoftware.minlog.Log; import org.objectweb.asm.*; import static net.orfjackal.retrolambda.util.Flags.*; @@ -47,7 +48,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si } private void printWarning(String methodKind, String methodName) { - System.out.println("WARNING: The interface " + interfaceName + " has " + methodKind + " \"" + methodName + "\" " + + Log.warn("The interface " + interfaceName + " has " + methodKind + " \"" + methodName + "\" " + "but backporting default methods is not enabled"); } } diff --git a/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/BackportLambdaInvocations.java b/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/BackportLambdaInvocations.java index c6ebcc30..a2e408f9 100644 --- a/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/BackportLambdaInvocations.java +++ b/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/BackportLambdaInvocations.java @@ -4,6 +4,7 @@ package net.orfjackal.retrolambda.lambdas; +import com.esotericsoftware.minlog.Log; import net.orfjackal.retrolambda.interfaces.*; import net.orfjackal.retrolambda.util.Bytecode; import org.objectweb.asm.*; @@ -42,10 +43,8 @@ private static void resetLambdaClassSequenceNumber() { AtomicInteger counter = (AtomicInteger) counterField.get(null); counter.set(0); } catch (Throwable t) { - // print to stdout to keep in sync with other log output - System.out.println("WARNING: Failed to start class numbering from one. Don't worry, it's cosmetic, " + - "but please file a bug report and tell on which JDK version this happened."); - t.printStackTrace(System.out); + Log.warn("Failed to start class numbering from one. Don't worry, it's cosmetic, " + + "but please file a bug report and tell on which JDK version this happened.", t); } } diff --git a/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/LambdaClassSaver.java b/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/LambdaClassSaver.java index 760807ac..f2d02a90 100644 --- a/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/LambdaClassSaver.java +++ b/retrolambda/src/main/java/net/orfjackal/retrolambda/lambdas/LambdaClassSaver.java @@ -1,9 +1,10 @@ -// Copyright © 2013-2015 Esko Luontola +// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors // This software is released under the Apache License 2.0. // The license text is at http://www.apache.org/licenses/LICENSE-2.0 package net.orfjackal.retrolambda.lambdas; +import com.esotericsoftware.minlog.Log; import net.orfjackal.retrolambda.Transformers; import net.orfjackal.retrolambda.files.OutputDirectory; import org.objectweb.asm.ClassReader; @@ -27,7 +28,7 @@ public void saveIfLambda(String className, byte[] bytecode) { } private void reifyLambdaClass(String className, byte[] bytecode) { - System.out.println("Saving lambda class: " + className); + Log.info("Saving lambda class: " + className); bytecode = transformers.backportLambdaClass(new ClassReader(bytecode)); try { saver.writeClass(bytecode);