diff --git a/logback-1.2.3-getCallerClass.patch b/logback-1.2.3-getCallerClass.patch new file mode 100644 index 0000000..4960505 --- /dev/null +++ b/logback-1.2.3-getCallerClass.patch @@ -0,0 +1,59 @@ +--- logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java 2019-11-29 12:40:38.797022563 +0100 ++++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java 2019-11-29 13:11:30.783272712 +0100 +@@ -17,7 +17,8 @@ + import java.security.CodeSource; + import java.util.HashMap; + +-import sun.reflect.Reflection; ++import java.lang.reflect.Method; ++import java.lang.reflect.InvocationTargetException; + + // import java.security.AccessControlException; import java.security.AccessController;import java.security.PrivilegedAction; + /** +@@ -32,27 +33,6 @@ + + HashMap cache = new HashMap(); + +- private static boolean GET_CALLER_CLASS_METHOD_AVAILABLE = false; // private static boolean +- // HAS_GET_CLASS_LOADER_PERMISSION = false; +- +- static { +- // if either the Reflection class or the getCallerClass method +- // are unavailable, then we won't invoke Reflection.getCallerClass() +- // This approach ensures that this class will *run* on JDK's lacking +- // sun.reflect.Reflection class. However, this class will *not compile* +- // on JDKs lacking sun.reflect.Reflection. +- try { +- Reflection.getCallerClass(2); +- GET_CALLER_CLASS_METHOD_AVAILABLE = true; +- } catch (NoClassDefFoundError e) { +- } catch (NoSuchMethodError e) { +- } catch (UnsupportedOperationException e) { +- } catch (Throwable e) { +- System.err.println("Unexpected exception"); +- e.printStackTrace(); +- } +- } +- + public void calculate(IThrowableProxy tp) { + while (tp != null) { + populateFrames(tp.getStackTraceElementProxyArray()); +@@ -81,8 +61,16 @@ + int missfireCount = 0; + for (int i = 0; i < commonFrames; i++) { + Class callerClass = null; +- if (GET_CALLER_CLASS_METHOD_AVAILABLE) { +- callerClass = Reflection.getCallerClass(localFirstCommon + i - missfireCount + 1); ++ try { ++ Class reflect = Class.forName("sun.reflect.Reflection"); ++ Method getCallerClass = reflect.getMethod("getCallerClass",Integer.TYPE); ++ callerClass = (Class)(getCallerClass.invoke(null, localFirstCommon + i - missfireCount + 1)); ++ } catch (ClassNotFoundException e) { ++ } catch (NoSuchMethodException e) { ++ } catch (IllegalAccessException e) { ++ } catch (InvocationTargetException e) { ++ System.err.println("Unexpected exception"); ++ e.printStackTrace(); + } + StackTraceElementProxy step = stepArray[stepFirstCommon + i]; + String stepClassname = step.ste.getClassName(); diff --git a/logback.changes b/logback.changes index 8c37323..f9b88f2 100644 --- a/logback.changes +++ b/logback.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Fri Nov 29 12:15:18 UTC 2019 - Fridrich Strba + +- Do not force building with java < 9 +- Specifiy maven.compiler.release=8 to access the + java.util.function.Supplier API, introduced in java 8 +- Added patch: + * logback-1.2.3-getCallerClass.patch + + Access the sun.reflect.Reflection.getCallerClass by + by reflection, in order to be able to build with jdk >= 9 + ------------------------------------------------------------------- Sun Nov 17 19:45:03 UTC 2019 - Fridrich Strba diff --git a/logback.spec b/logback.spec index 21dc7df..25005cf 100644 --- a/logback.spec +++ b/logback.spec @@ -1,7 +1,7 @@ # # spec file for package logback # -# Copyright (c) 2019 SUSE LLC. +# Copyright (c) 2019 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,9 +25,9 @@ URL: https://logback.qos.ch/ Source0: %{name}-%{version}.tar.xz # Remove deprecated methods Patch0: %{name}-1.1.11-jetty.patch +Patch1: logback-1.2.3-getCallerClass.patch BuildRequires: fdupes BuildRequires: maven-local -BuildRequires: maven-local BuildRequires: mvn(javax.mail:mail) BuildRequires: mvn(javax.servlet:javax.servlet-api) BuildRequires: mvn(junit:junit) @@ -45,7 +45,6 @@ BuildRequires: mvn(org.eclipse.jetty:jetty-util) BuildRequires: mvn(org.fusesource.jansi:jansi) BuildRequires: mvn(org.slf4j:slf4j-api) BuildRequires: mvn(org.slf4j:slf4j-ext) -BuildConflicts: java-devel >= 9 #!BuildRequires: groovy-lib BuildArch: noarch @@ -91,6 +90,7 @@ find . -type f -exec chmod -x {} \; chmod +x %{name}-examples/src/main/resources/setClasspath.sh %patch0 -p1 +%patch1 -p1 %pom_remove_plugin :maven-source-plugin %pom_remove_plugin :findbugs-maven-plugin @@ -125,6 +125,9 @@ rm -r %{name}-*/src/test/java/* # unavailable test dep maven-scala-plugin # slf4jJAR and org.apache.felix.main are required by logback-examples modules for maven-antrun-plugin %{mvn_build} -f -- \ +%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 9}%{!?pkg_vcmp:0} + -Dmaven.compiler.release=8 \ +%endif -Dorg.slf4j:slf4j-api:jar=$(build-classpath slf4j/api) \ -Dorg.apache.felix:org.apache.felix.main:jar=$(build-classpath felix/org.apache.felix.main)