[openwebbeans] branch master updated: upgrade junit
This is an automated email from the ASF dual-hosted git repository. struberg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git The following commit(s) were added to refs/heads/master by this push: new 8e14e10 upgrade junit 8e14e10 is described below commit 8e14e10a33627ab10e89e6fd2947ec625d4df2bf Author: Mark Struberg AuthorDate: Mon Mar 15 21:10:58 2021 +0100 upgrade junit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 54a58ac..77503e5 100644 --- a/pom.xml +++ b/pom.xml @@ -725,7 +725,7 @@ junit junit -4.13.1 +4.13.2 test
[openwebbeans] branch master updated: [OWB-1378] enable to bypass application scoped lifecycle events in SE mode if org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents=false
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git The following commit(s) were added to refs/heads/master by this push: new 8c2215c [OWB-1378] enable to bypass application scoped lifecycle events in SE mode if org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents=false 8c2215c is described below commit 8c2215c5782449d48ec97e629c610e5475a1a976 Author: Romain Manni-Bucau AuthorDate: Mon Mar 15 20:53:33 2021 +0100 [OWB-1378] enable to bypass application scoped lifecycle events in SE mode if org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents=false --- .../webbeans/corespi/se/BaseSeContextsService.java | 27 +- .../webbeans/lifecycle/StandaloneLifeCycle.java| 13 +++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java index 9bd65cb..3df8f18 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java @@ -355,26 +355,41 @@ public abstract class BaseSeContextsService extends AbstractContextsService { createSingletonContext(); -webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( -new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED); +if (fireApplicationScopeEvents()) +{ +webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( +new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED); +} } private void stopApplicationContext() { if(applicationContext != null && !applicationContext.isDestroyed()) { -webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( -new Object(), BeforeDestroyedLiteral.INSTANCE_APPLICATION_SCOPED); +final boolean fireApplicationScopeEvents = fireApplicationScopeEvents(); +if (fireApplicationScopeEvents) +{ +webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( +new Object(), BeforeDestroyedLiteral.INSTANCE_APPLICATION_SCOPED); +} applicationContext.destroy(); // this is needed to get rid of ApplicationScoped beans which are cached inside the proxies... WebBeansContext.currentInstance().getBeanManagerImpl().clearCacheProxies(); -webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( -new Object(), DestroyedLiteral.INSTANCE_APPLICATION_SCOPED); +if (fireApplicationScopeEvents) +{ +webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( +new Object(), DestroyedLiteral.INSTANCE_APPLICATION_SCOPED); +} } } +public boolean fireApplicationScopeEvents() +{ +return Boolean.parseBoolean(webBeansContext.getOpenWebBeansConfiguration() + .getProperty("org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents", "true")); +} private void stopConversationContext() { diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java b/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java index 8d90fbf..cfb6e73 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.apache.webbeans.annotation.InitializedLiteral; import org.apache.webbeans.config.WebBeansFinder; +import org.apache.webbeans.corespi.se.BaseSeContextsService; import org.apache.webbeans.el.ELContextStore; import org.apache.webbeans.logger.WebBeansLoggerFacade; import org.apache.webbeans.util.WebBeansUtil; @@ -58,10 +59,14 @@ public class StandaloneLifeCycle extends AbstractLifeCycle @Override protected void afterStartApplication(Object startupObject) { -// the ApplicationContext is already started, but we fire -// the event again as the userland beans are only available now -webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( -new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED); +if (!BaseSeContextsService.class.isInstance(webBeansContext.getContextsService()) || + BaseSeContextsService.class.cast(webBeansContext.getContextsService()).fireApplicationScopeEvents()) +{ +// the ApplicationContext is already started, but we
[openwebbeans] branch master updated: OWB-1375 simplify defineClass handling
This is an automated email from the ASF dual-hosted git repository. struberg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git The following commit(s) were added to refs/heads/master by this push: new 82e65b4 OWB-1375 simplify defineClass handling 82e65b4 is described below commit 82e65b4a55e18ed3c67f435cd4ef05cac0c4ab34 Author: Mark Struberg AuthorDate: Mon Mar 15 20:33:02 2021 +0100 OWB-1375 simplify defineClass handling --- .../java/org/apache/webbeans/proxy/Unsafe.java | 70 +- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java index d85dbd5..7ba6d20 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java @@ -26,8 +26,6 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.ProtectionDomain; -import java.util.HashMap; -import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -50,8 +48,8 @@ public class Unsafe private final AtomicReference unsafeDefineClass = new AtomicReference<>(); // defineClass method on ClassLoader -private Boolean useDefineClassMethod = null; -private final Map defineClassMethodsByClassLoader = new HashMap<>(); +private volatile boolean useDefineClassMethod = true; +private volatile Method defineClassMethod = null; // java 16 private volatile Method privateLookup; @@ -148,54 +146,42 @@ public class Unsafe Class parent) throws ProxyGenerationException { -Method defineClassMethod = null; -if (useDefineClassMethod == null || Boolean.TRUE.equals(useDefineClassMethod)) +if (defineClassMethod == null && useDefineClassMethod) { -defineClassMethod = defineClassMethodsByClassLoader.get(classLoader); - -if (defineClassMethod == null) +Method defineClassMethodTmp = null; +try { -Class clClazz = classLoader.getClass(); - -do -{ -try -{ -defineClassMethod = clClazz.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); -} -catch (NoSuchMethodException e) -{ -// do nothing, we need to search the superclass -} +// defineClass is a final method on the abstract base ClassLoader +// thus we need to cache it only once +defineClassMethodTmp = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); +} +catch (NoSuchMethodException e) +{ +// all fine, we just skip over from here +} -clClazz = clClazz.getSuperclass(); -} while (defineClassMethod == null && clClazz != Object.class); -if (defineClassMethod == null) -{ -// This ClassLoader does not have any accessible defineClass method -useDefineClassMethod = Boolean.FALSE; -} -else if (!defineClassMethod.isAccessible()) +if (defineClassMethodTmp == null) +{ +// This ClassLoader does not have any accessible defineClass method +useDefineClassMethod = false; +} +else if (!defineClassMethodTmp.isAccessible()) +{ +try { -try -{ -defineClassMethod.setAccessible(true); -defineClassMethodsByClassLoader.put(classLoader, defineClassMethod); -} -catch (RuntimeException re) -{ -// likely j9 or not accessible via security, let's use unsafe -defineClassMethod = null; -useDefineClassMethod = Boolean.FALSE; -} +defineClassMethodTmp.setAccessible(true); } -else +catch (RuntimeException re) { -defineClassMethodsByClassLoader.put(classLoader, defineClassMethod); +// likely j9 or not accessible via security, let's use unsafe or MethodHandle as fallbacks +defineClassMethodTmp = null; +useDefineClassMethod =
[openwebbeans] branch master updated: OWB-1375 cache hit and miss
This is an automated email from the ASF dual-hosted git repository. struberg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git The following commit(s) were added to refs/heads/master by this push: new 6ae21f8 OWB-1375 cache hit and miss 6ae21f8 is described below commit 6ae21f87d54f47780ef76124ddcc89fa255e4370 Author: Mark Struberg AuthorDate: Mon Mar 15 19:04:05 2021 +0100 OWB-1375 cache hit and miss We do not need to try our different classdefine strategies every time. Either they work everytime or not at all. So we can cache those. For Java8 we an even cache away the reflect Method per ClassLoader. --- .../java/org/apache/webbeans/proxy/Unsafe.java | 71 +++--- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java index 850b523..d85dbd5 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java @@ -26,6 +26,8 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.ProtectionDomain; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -47,6 +49,10 @@ public class Unsafe private Method unsafeAllocateInstance; private final AtomicReference unsafeDefineClass = new AtomicReference<>(); +// defineClass method on ClassLoader +private Boolean useDefineClassMethod = null; +private final Map defineClassMethodsByClassLoader = new HashMap<>(); + // java 16 private volatile Method privateLookup; private Method defineClass; @@ -142,32 +148,53 @@ public class Unsafe Class parent) throws ProxyGenerationException { -Class clazz = classLoader.getClass(); - Method defineClassMethod = null; -do + +if (useDefineClassMethod == null || Boolean.TRUE.equals(useDefineClassMethod)) { -try -{ -defineClassMethod = clazz.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); -} -catch (NoSuchMethodException e) +defineClassMethod = defineClassMethodsByClassLoader.get(classLoader); + +if (defineClassMethod == null) { -// do nothing, we need to search the superclass -} +Class clClazz = classLoader.getClass(); -clazz = clazz.getSuperclass(); -} while (defineClassMethod == null && clazz != Object.class); +do +{ +try +{ +defineClassMethod = clClazz.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); +} +catch (NoSuchMethodException e) +{ +// do nothing, we need to search the superclass +} -if (defineClassMethod != null && !defineClassMethod.isAccessible()) -{ -try -{ -defineClassMethod.setAccessible(true); -} -catch (RuntimeException re) // likely j9, let's use unsafe -{ -defineClassMethod = null; +clClazz = clClazz.getSuperclass(); +} while (defineClassMethod == null && clClazz != Object.class); + +if (defineClassMethod == null) +{ +// This ClassLoader does not have any accessible defineClass method +useDefineClassMethod = Boolean.FALSE; +} +else if (!defineClassMethod.isAccessible()) +{ +try +{ +defineClassMethod.setAccessible(true); +defineClassMethodsByClassLoader.put(classLoader, defineClassMethod); +} +catch (RuntimeException re) +{ +// likely j9 or not accessible via security, let's use unsafe +defineClassMethod = null; +useDefineClassMethod = Boolean.FALSE; +} +} +else +{ +defineClassMethodsByClassLoader.put(classLoader, defineClassMethod); +} } } @@ -178,10 +205,10 @@ public class Unsafe if (defineClassMethod != null) { definedClass = (Class)
[openwebbeans] branch master updated: [OWB-1377][OWB-1375] enable to configure reserved packages for proxies + handle org.apache.webbeans.custom.signed. as org.apache.webbeans.custom.
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git The following commit(s) were added to refs/heads/master by this push: new 2f54115 [OWB-1377][OWB-1375] enable to configure reserved packages for proxies + handle org.apache.webbeans.custom.signed. as org.apache.webbeans.custom. 2f54115 is described below commit 2f54115c404e40aefd390168f511511649423cc1 Author: Romain Manni-Bucau AuthorDate: Mon Mar 15 17:25:17 2021 +0100 [OWB-1377][OWB-1375] enable to configure reserved packages for proxies + handle org.apache.webbeans.custom.signed. as org.apache.webbeans.custom. --- .../webbeans/config/OpenWebBeansConfiguration.java | 42 ++ .../signed/CustomSignedProxyPackageMarker.java | 23 .../webbeans/proxy/AbstractProxyFactory.java | 10 -- .../java/org/apache/webbeans/proxy/Unsafe.java | 7 ++-- .../META-INF/openwebbeans/openwebbeans.properties | 6 5 files changed, 83 insertions(+), 5 deletions(-) diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java b/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java index 3810268..1a5a6d5 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java @@ -31,10 +31,14 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.logging.Level; +import java.util.stream.Stream; import org.apache.webbeans.exception.WebBeansConfigurationException; import org.apache.webbeans.logger.WebBeansLoggerFacade; +import static java.util.Arrays.asList; +import static java.util.stream.Collectors.toList; + /** * Defines configuration for OpenWebBeans. * @@ -244,6 +248,15 @@ public class OpenWebBeansConfiguration */ private Map> configuredLists = new HashMap<>(); +/** + * List of packages which can't be used to generate a proxy. + * + * Important: changing this default has runtime impacts on proxies name. + *It is recommended to not tune it until really needed. + *Also ensure it is consistent between generation and runtime if you use stable proxy names. + */ +private volatile List proxyReservedPackages; + /** * you can configure this externally as well. @@ -556,4 +569,33 @@ public class OpenWebBeansConfiguration return Boolean.parseBoolean(getProperty( "org.apache.webbeans.spi.deployer.skipNoClassDefFoundTriggers")); } + +public List getProxyReservedPackages() +{ +if (proxyReservedPackages == null) +{ +synchronized (this) +{ +if (proxyReservedPackages == null) +{ +final String conf = getProperty("org.apache.webbeans.generator.proxyReservedPackages"); +if (conf == null) +{ +proxyReservedPackages = asList("java.", "javax.", "sun.misc."); +} +else +{ +proxyReservedPackages = Stream.concat( +Stream.of("java.", "javax.", "sun.misc."), +Stream.of(conf.split(",")) +.map(String::trim) +.filter(it -> !it.isEmpty())) +.distinct() +.collect(toList()); +} +} +} +} +return proxyReservedPackages; +} } diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/custom/signed/CustomSignedProxyPackageMarker.java b/webbeans-impl/src/main/java/org/apache/webbeans/custom/signed/CustomSignedProxyPackageMarker.java new file mode 100644 index 000..70ce1eb --- /dev/null +++ b/webbeans-impl/src/main/java/org/apache/webbeans/custom/signed/CustomSignedProxyPackageMarker.java @@ -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
[openwebbeans] branch master updated: [OWB-1375] first step to use privateLookup for java 16 and drop --add-exports need (still need to optimize the defineClass strategy - ensure it is adapted to the
This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git The following commit(s) were added to refs/heads/master by this push: new 14ee3ef [OWB-1375] first step to use privateLookup for java 16 and drop --add-exports need (still need to optimize the defineClass strategy - ensure it is adapted to the runtime and does not rely on fallbacks) 14ee3ef is described below commit 14ee3ef408c8c1b9962d91f6cb4f882ec61eb1d3 Author: Romain Manni-Bucau AuthorDate: Mon Mar 15 17:06:38 2021 +0100 [OWB-1375] first step to use privateLookup for java 16 and drop --add-exports need (still need to optimize the defineClass strategy - ensure it is adapted to the runtime and does not rely on fallbacks) --- pom.xml| 19 --- .../webbeans/custom/CustomProxyPackageMarker.java | 23 .../webbeans/proxy/AbstractProxyFactory.java | 4 +- .../java/org/apache/webbeans/proxy/Unsafe.java | 65 -- 4 files changed, 84 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 2ff13a5..54a58ac 100644 --- a/pom.xml +++ b/pom.xml @@ -848,25 +848,6 @@ -java16-hacks - -16 - - - - -org.apache.maven.plugins -maven-surefire-plugin - ---add-exports java.base/jdk.internal.misc=ALL-UNNAMED - - - - - - - - reporting diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/custom/CustomProxyPackageMarker.java b/webbeans-impl/src/main/java/org/apache/webbeans/custom/CustomProxyPackageMarker.java new file mode 100644 index 000..8a14770 --- /dev/null +++ b/webbeans-impl/src/main/java/org/apache/webbeans/custom/CustomProxyPackageMarker.java @@ -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. + */ +package org.apache.webbeans.custom; + +public interface CustomProxyPackageMarker +{ +} diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java index f66d03b..47c67aa 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java @@ -289,7 +289,7 @@ public abstract class AbstractProxyFactory if (className.startsWith(forbiddenPackagePrefix)) { -fixedClassName = "org.apache.webbeans.custom." + className.substring(forbiddenPackagePrefix.length()); +fixedClassName = "org.apache.webbeans.custom." + className.substring(className.lastIndexOf('.') + 1); } return fixedClassName; @@ -329,7 +329,7 @@ public abstract class AbstractProxyFactory { return definingService.defineAndLoad(proxyClassName, proxyBytes, classToProxy); } -return unsafe.defineAndLoadClass(classLoader, proxyClassName, proxyBytes); +return unsafe.defineAndLoadClass(classLoader, proxyClassName, proxyBytes, classToProxy); } protected T newInstance(final Class proxyClass) diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java index 9beb112..f0b49c3 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/proxy/Unsafe.java @@ -18,6 +18,7 @@ */ package org.apache.webbeans.proxy; +import java.lang.invoke.MethodHandles; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.IntStream; import java.util.stream.Stream; +import
svn commit: r1072392 - in /websites: production/openwebbeans/content/index.html staging/openwebbeans/trunk/content/index.html
Author: buildbot Date: Mon Mar 15 10:35:07 2021 New Revision: 1072392 Log: Dynamic update by buildbot for openwebbeans Modified: websites/production/openwebbeans/content/index.html websites/staging/openwebbeans/trunk/content/index.html Modified: websites/production/openwebbeans/content/index.html == (empty) Modified: websites/staging/openwebbeans/trunk/content/index.html == (empty)