This is an automated email from the ASF dual-hosted git repository. ggrzybek pushed a commit to branch KARAF-5376-overrides_v2 in repository https://gitbox.apache.org/repos/asf/karaf.git
commit 07bbb7d465427dd3cb394b815ec7f6d2b3f58cbe Author: Grzegorz Grzybek <[email protected]> AuthorDate: Fri Nov 10 12:16:11 2017 +0100 Revert "[KARAF-5416] Remove support for ext and endorsed libraries for Java 9 compatibility" This reverts commit 3f1f44b6521f058abea6f6df19ce03a4c353c991. --- assemblies/features/base/pom.xml | 10 ++ .../main/filtered-resources/resources/bin/karaf | 6 + .../filtered-resources/resources/bin/karaf.bat | 2 + .../src/main/resources/resources/lib/boot/README | 21 +++ .../main/resources/resources/lib/endorsed/README | 23 +++ assemblies/features/framework/pom.xml | 5 + exception/NOTICE | 67 +++++++ exception/pom.xml | 38 ++++ exception/src/main/java/java/lang/Exception.java | 194 +++++++++++++++++++++ .../main/asciidoc/user-guide/os-integration.adoc | 2 + pom.xml | 6 + .../org/apache/karaf/profile/assembly/Builder.java | 4 - .../karaf/wrapper/internal/unix/karaf-wrapper.conf | 4 +- .../wrapper/internal/windows/karaf-wrapper.conf | 4 +- .../wrapper/internal/windows64/karaf-wrapper.conf | 4 +- 15 files changed, 383 insertions(+), 7 deletions(-) diff --git a/assemblies/features/base/pom.xml b/assemblies/features/base/pom.xml index 072c1bf..d14c041 100644 --- a/assemblies/features/base/pom.xml +++ b/assemblies/features/base/pom.xml @@ -44,6 +44,11 @@ </dependency> <dependency> <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.exception</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf</groupId> <artifactId>org.apache.karaf.client</artifactId> <scope>runtime</scope> </dependency> @@ -130,6 +135,11 @@ <outputDirectory>target/classes/resources/system/org/apache/karaf/org.apache.karaf.client/${project.version}</outputDirectory> </artifactItem> <artifactItem> + <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.exception</artifactId> + <outputDirectory>target/classes/resources/lib/endorsed</outputDirectory> + </artifactItem> + <artifactItem> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.framework</artifactId> <outputDirectory>target/classes/resources/system/org/apache/felix/org.apache.felix.framework/${felix.framework.version}</outputDirectory> diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf index a70a896..674b8d0 100644 --- a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf +++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf @@ -155,8 +155,12 @@ run() { if [ "x$CHECK_ROOT_INSTANCE_RUNNING" = "x" ]; then CHECK_ROOT_INSTANCE_RUNNING=true fi + JAVA_ENDORSED_DIRS="${JAVA_HOME}/jre/lib/endorsed:${JAVA_HOME}/lib/endorsed:${KARAF_HOME}/lib/endorsed" + JAVA_EXT_DIRS="${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${KARAF_HOME}/lib/ext" if ${cygwin}; then JAVA_HOME=$(cygpath --path --windows "${JAVA_HOME}") + JAVA_ENDORSED_DIRS=$(cygpath --path --windows "${JAVA_ENDORSED_DIRS}") + JAVA_EXT_DIRS=$(cygpath --path --windows "${JAVA_EXT_DIRS}") fi convertPaths cd "${KARAF_BASE}" || exit 2 @@ -290,6 +294,8 @@ run() { ${MAIN} "$@" else ${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \ + -Djava.endorsed.dirs="${JAVA_ENDORSED_DIRS}" \ + -Djava.ext.dirs="${JAVA_EXT_DIRS}" \ -Dkaraf.instances="${KARAF_HOME}/instances" \ -Dkaraf.home="${KARAF_HOME}" \ -Dkaraf.base="${KARAF_BASE}" \ diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat index 0cb31c2..1f95c21 100644 --- a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat +++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat @@ -414,6 +414,8 @@ if "%KARAF_PROFILER%" == "" goto :RUN ) else ( "%JAVA%" %JAVA_OPTS% %OPTS% ^ -classpath "%CLASSPATH%" ^ + -Djava.endorsed.dirs="%JAVA_HOME%\jre\lib\endorsed;%JAVA_HOME%\lib\endorsed;%KARAF_HOME%\lib\endorsed" ^ + -Djava.ext.dirs="%JAVA_HOME%\jre\lib\ext;%JAVA_HOME%\lib\ext;%KARAF_HOME%\lib\ext" ^ -Dkaraf.instances="%KARAF_HOME%\instances" ^ -Dkaraf.home="%KARAF_HOME%" ^ -Dkaraf.base="%KARAF_BASE%" ^ diff --git a/assemblies/features/base/src/main/resources/resources/lib/boot/README b/assemblies/features/base/src/main/resources/resources/lib/boot/README new file mode 100644 index 0000000..b3a06ce --- /dev/null +++ b/assemblies/features/base/src/main/resources/resources/lib/boot/README @@ -0,0 +1,21 @@ +################################################################################ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +Any jar in this folder will be added to the classpath by the JVM and will be +available to the Main class. Custom locking libraries can be added here. diff --git a/assemblies/features/base/src/main/resources/resources/lib/endorsed/README b/assemblies/features/base/src/main/resources/resources/lib/endorsed/README new file mode 100644 index 0000000..0665a52 --- /dev/null +++ b/assemblies/features/base/src/main/resources/resources/lib/endorsed/README @@ -0,0 +1,23 @@ +################################################################################ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +This directory is the Java endorsed directory. +Any jar in this folder will be used to override classes defined by the JVM. +For more information, see: + http://download.oracle.com/javase/6/docs/technotes/guides/standards/ diff --git a/assemblies/features/framework/pom.xml b/assemblies/features/framework/pom.xml index a55051c..61525b8 100644 --- a/assemblies/features/framework/pom.xml +++ b/assemblies/features/framework/pom.xml @@ -51,6 +51,11 @@ </dependency> <dependency> <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.exception</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf</groupId> <artifactId>org.apache.karaf.client</artifactId> <scope>runtime</scope> </dependency> diff --git a/exception/NOTICE b/exception/NOTICE new file mode 100644 index 0000000..f1f81e0 --- /dev/null +++ b/exception/NOTICE @@ -0,0 +1,67 @@ +Apache Karaf +Copyright 2010-2014 The Apache Software Foundation + + +I. Included Software + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). +Licensed under the Apache License 2.0. + +This product uses software developed at +The OSGi Alliance (http://www.osgi.org/). +Copyright (c) OSGi Alliance (2000, 2010). +Licensed under the Apache License 2.0. + +This product includes software developed at +OW2 (http://www.ow2.org/). +Licensed under the BSD License. + +This product includes software developed at +OPS4J (http://www.ops4j.org/). +Licensed under the Apache License 2.0. + +This product includes software developed at +Eclipse Foundation (http://www.eclipse.org/). +Licensed under the EPL. + +This product includes software written by +Antony Lesuisse. +Licensed under Public Domain. + + +II. Used Software + +This product uses software developed at +FUSE Source (http://www.fusesource.org/). +Licensed under the Apache License 2.0. + +This product uses software developed at +AOP Alliance (http://aopalliance.sourceforge.net/). +Licensed under the Public Domain. + +This product uses software developed at +Tanuki Software (http://www.tanukisoftware.com/). +Licensed under the Apache License 2.0. + +This product uses software developed at +Jasypt (http://jasypt.sourceforge.net/). +Licensed under the Apache License 2.0. + +This product uses software developed at +JLine (https://github.com/jline/). +Licensed under the BSD License. + +This product uses software developed at +SLF4J (http://www.slf4j.org/). +Licensed under the MIT License. + +This product uses software developed at +SpringSource (http://www.springsource.org/). +Licensed under the Apache License 2.0. + +III. License Summary +- Apache License 2.0 +- BSD License +- EPL License +- MIT License diff --git a/exception/pom.xml b/exception/pom.xml new file mode 100644 index 0000000..370ddb6 --- /dev/null +++ b/exception/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.karaf</groupId> + <artifactId>karaf</artifactId> + <version>4.2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>org.apache.karaf.exception</artifactId> + <name>Apache Karaf :: Exception</name> + + <properties> + <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory> + </properties> + +</project> diff --git a/exception/src/main/java/java/lang/Exception.java b/exception/src/main/java/java/lang/Exception.java new file mode 100644 index 0000000..940658b --- /dev/null +++ b/exception/src/main/java/java/lang/Exception.java @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.lang; + +import java.lang.reflect.Field; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; + +import javax.xml.bind.annotation.XmlTransient; + + +/** + * {@code Exception} is the superclass of all classes that represent recoverable + * exceptions. When exceptions are thrown, they may be caught by application + * code. + * + * @see Throwable + * @see Error + * @see RuntimeException + */ +public class Exception extends Throwable { + private static final long serialVersionUID = -3387516993124229948L; + + private transient Reference<Class<?>>[] classContext = null; + + /** + * Constructs a new {@code Exception} that includes the current stack trace. + */ + public Exception() { + super(); + initClassContext(); + } + + /** + * Constructs a new {@code Exception} with the current stack trace and the + * specified detail message. + * + * @param detailMessage + * the detail message for this exception. + */ + public Exception(String detailMessage) { + super(detailMessage); + initClassContext(); + } + + /** + * Constructs a new {@code Exception} with the current stack trace, the + * specified detail message and the specified cause. + * + * @param detailMessage + * the detail message for this exception. + * @param throwable + * the cause of this exception. + */ + public Exception(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + initClassContext(); + } + + /** + * Constructs a new {@code Exception} with the current stack trace and the + * specified cause. + * + * @param throwable + * the cause of this exception. + */ + public Exception(Throwable throwable) { + super(throwable); + initClassContext(); + } + + /** + * Constructs a new exception with the specified detail message, + * cause, suppression enabled or disabled, and writable stack + * trace enabled or disabled. + * + * @param message the detail message. + * @param cause the cause. (A {@code null} value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @param enableSuppression whether or not suppression is enabled + * or disabled + * @param writableStackTrace whether or not the stack trace should + * be writable + */ + protected Exception(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + try { + Field field = null; + if (writableStackTrace) { + fillInStackTrace(); + } else { + field = Throwable.class.getDeclaredField("stackTrace"); + field.setAccessible(true); + field.set(this, null); + } + field = Throwable.class.getDeclaredField("detailMessage"); + field.setAccessible(true); + field.set(this, message); + field = Throwable.class.getDeclaredField("cause"); + field.setAccessible(true); + field.set(this, cause); + if (!enableSuppression) { + field = Throwable.class.getDeclaredField("suppressedExceptions"); + field.setAccessible(true); + field.set(this, null); + } + } catch (Exception e) { + e.printStackTrace(); + } + initClassContext(); + } + + @XmlTransient + @Deprecated + public Class[] getClassContext() { + Class<?>[] context = null; + if (classContext != null) { + context = new Class<?>[classContext.length]; + for (int i = 0; i < classContext.length; i++) { + Class<?> c = classContext[i].get(); + context[i] = c == null ? Object.class : c; + } + } + return context; + } + + @SuppressWarnings("unchecked") + private void initClassContext() { + Class[] context = SecurityManagerEx.getInstance().getThrowableContext(this); + if (context != null) { + classContext = new Reference[context.length]; + for (int i = 0; i < context.length; i++) { + classContext[i] = new WeakReference<Class<?>>(context[i]); + } + } + } + + protected Class[] classContext() { + Class<?>[] context = new Class<?>[classContext.length]; + for (int i = 0; i < classContext.length; i++) { + Class<?> c = classContext[i].get(); + context[i] = c == null ? Object.class : c; + } + return context; + } + + private static class SecurityManagerEx extends SecurityManager + { + + private static SecurityManagerEx sm; + + public static SecurityManagerEx getInstance() { + // No synchronized block because we don't really care + // if multiple instances are created at some point + if (sm == null) { + sm = new SecurityManagerEx(); + } + return sm; + } + + public Class[] getThrowableContext(Throwable t) { + try { + Class[] context = getClassContext(); + int nb = 0; + for (;;) { + if (context[context.length - 1 - nb] == t.getClass()) { + break; + } + nb++; + } + Class[] nc = new Class[nb]; + System.arraycopy(context, context.length - nb, nc, 0, nb); + return nc; + } catch (Exception e) { + return null; + } + } + } + +} diff --git a/manual/src/main/asciidoc/user-guide/os-integration.adoc b/manual/src/main/asciidoc/user-guide/os-integration.adoc index 70022e4..b6310a1 100644 --- a/manual/src/main/asciidoc/user-guide/os-integration.adoc +++ b/manual/src/main/asciidoc/user-guide/os-integration.adoc @@ -291,6 +291,8 @@ wrapper.java.additional.4=-Dkaraf.etc=%KARAF_ETC% wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dkaraf.startLocalConsole=false wrapper.java.additional.7=-Dkaraf.startRemoteShell=true +wrapper.java.additional.8=-Djava.endorsed.dirs=%JAVA_HOME%/jre/lib/endorsed:%JAVA_HOME%/lib/endorsed:%KARAF_HOME%/lib/endorsed +wrapper.java.additional.9=-Djava.ext.dirs=%JAVA_HOME%/jre/lib/ext:%JAVA_HOME%/lib/ext:%KARAF_HOME%/lib/ext # Uncomment to enable jmx #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616 diff --git a/pom.xml b/pom.xml index 215eb11..6bead48 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,7 @@ <module>web</module> <module>wrapper</module> <module>webconsole</module> + <module>exception</module> <module>scheduler</module> <module>scr</module> <module>diagnostic</module> @@ -390,6 +391,11 @@ </dependency> <dependency> <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.exception</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.karaf</groupId> <artifactId>org.apache.karaf.client</artifactId> <version>${project.version}</version> </dependency> diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index d9e156d..e48b6cf 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -715,10 +715,6 @@ public class Builder { } final String type = clause.getDirective(LIBRARY_CLAUSE_TYPE) != null ? clause.getDirective(LIBRARY_CLAUSE_TYPE) : Library.TYPE_DEFAULT; - if (type == Library.TYPE_ENDORSED || type == Library.TYPE_EXTENSION) { - LOGGER.warn("Ignoring library " + library + " which is of an unsupported type " + type + "."); - continue; - } final String path; switch (type) { case Library.TYPE_ENDORSED: path = "lib/endorsed"; break; diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper.conf b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper.conf index 9bc2f9c..38c1afe 100644 --- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper.conf +++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper.conf @@ -44,7 +44,9 @@ wrapper.java.additional.4=-Dkaraf.etc=%KARAF_ETC% wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dkaraf.startLocalConsole=false wrapper.java.additional.7=-Dkaraf.startRemoteShell=true -wrapper.java.additional.8=-Djava.io.tmpdir=%KARAF_DATA%/tmp +wrapper.java.additional.8=-Djava.endorsed.dirs=%JAVA_HOME%/jre/lib/endorsed:%JAVA_HOME%/lib/endorsed:%KARAF_HOME%/lib/endorsed +wrapper.java.additional.9=-Djava.ext.dirs=%JAVA_HOME%/jre/lib/ext:%JAVA_HOME%/lib/ext:%KARAF_HOME%/lib/ext +wrapper.java.additional.10=-Djava.io.tmpdir=%KARAF_DATA%/tmp # Uncomment to enable jmx #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616 diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper.conf b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper.conf index 4765361..426761d 100644 --- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper.conf +++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper.conf @@ -44,7 +44,9 @@ wrapper.java.additional.4=-Dkaraf.etc="%KARAF_ETC%" wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dkaraf.startLocalConsole=false wrapper.java.additional.7=-Dkaraf.startRemoteShell=true -wrapper.java.additional.8=-Djava.io.tmpdir="%KARAF_DATA%/tmp" +wrapper.java.additional.8=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed" +wrapper.java.additional.9=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext" +wrapper.java.additional.10=-Djava.io.tmpdir="%KARAF_DATA%/tmp" # Uncomment to enable jmx #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616 diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper.conf b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper.conf index 4765361..426761d 100644 --- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper.conf +++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper.conf @@ -44,7 +44,9 @@ wrapper.java.additional.4=-Dkaraf.etc="%KARAF_ETC%" wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dkaraf.startLocalConsole=false wrapper.java.additional.7=-Dkaraf.startRemoteShell=true -wrapper.java.additional.8=-Djava.io.tmpdir="%KARAF_DATA%/tmp" +wrapper.java.additional.8=-Djava.endorsed.dirs="%JAVA_HOME%/jre/lib/endorsed;%JAVA_HOME%/lib/endorsed;%KARAF_HOME%/lib/endorsed" +wrapper.java.additional.9=-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext;%JAVA_HOME%/lib/ext;%KARAF_HOME%/lib/ext" +wrapper.java.additional.10=-Djava.io.tmpdir="%KARAF_DATA%/tmp" # Uncomment to enable jmx #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616 -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
