[openjpa] 02/02: excluding asm too

2020-07-23 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch 
OPENJPA-2817_PCClassFileTransformer-exclusions
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit 1c14bc28cb399e32afba5e59d4b23c6eb6ad3067
Author: Romain Manni-Bucau 
AuthorDate: Tue Jul 14 20:25:00 2020 +0200

excluding asm too
---
 .../main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
index 45bc953..f0ac151 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
@@ -143,7 +143,8 @@ public class PCClassFileTransformer
 if (className.startsWith("org/apache/")) {
 final String sub = className.substring("org/apache/".length());
 if (sub.startsWith("openjpa/") ||
-sub.startsWith("commons/")) {
+sub.startsWith("commons/") ||
+sub.startsWith("xbean/")) {
 return true;
 }
 }



[openjpa] branch OPENJPA-2817_PCClassFileTransformer-exclusions updated (9e665c0 -> 1c14bc2)

2020-07-23 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a change to branch 
OPENJPA-2817_PCClassFileTransformer-exclusions
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


omit 9e665c0  Merge branch 'master' into 
OPENJPA-2817_PCClassFileTransformer-exclusions
omit 96b2b12  excluding asm too
omit 763e20c  OPENJPA-2817 dropping _transforming from 
PCClassFileTransformer and replace it by a minimal exclusion list
 new fd70273  OPENJPA-2817 dropping _transforming from 
PCClassFileTransformer and replace it by a minimal exclusion list
 new 1c14bc2  excluding asm too

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (9e665c0)
\
 N -- N -- N   
refs/heads/OPENJPA-2817_PCClassFileTransformer-exclusions (1c14bc2)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/openjpa/enhance/PCClassFileTransformer.java | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)



[openjpa] 01/02: OPENJPA-2817 dropping _transforming from PCClassFileTransformer and replace it by a minimal exclusion list

2020-07-23 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch 
OPENJPA-2817_PCClassFileTransformer-exclusions
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit fd70273f246255e86411bc4ed738860bd5cdc8f6
Author: Romain Manni-Bucau 
AuthorDate: Tue Jul 14 19:38:48 2020 +0200

OPENJPA-2817 dropping _transforming from PCClassFileTransformer and replace 
it by a minimal exclusion list
---
 .../openjpa/enhance/PCClassFileTransformer.java| 78 +++---
 1 file changed, 53 insertions(+), 25 deletions(-)

diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
index d67fb48..45bc953 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
@@ -55,7 +55,6 @@ public class PCClassFileTransformer
 private final ClassLoader _tmpLoader;
 private final Log _log;
 private final Set _names;
-private boolean _transforming = false;
 
 /**
  * Constructor.
@@ -64,7 +63,8 @@ public class PCClassFileTransformer
  * @param opts enhancer configuration options
  * @param loader temporary class loader for loading intermediate classes
  */
-public PCClassFileTransformer(MetaDataRepository repos, Options opts, 
ClassLoader loader) {
+public PCClassFileTransformer(MetaDataRepository repos, Options opts,
+ClassLoader loader) {
 this(repos, toFlags(opts), loader, opts.removeBooleanProperty
 ("scanDevPath", "ScanDevPath", false));
 }
@@ -105,6 +105,9 @@ public class PCClassFileTransformer
 _log.info(_loc.get("runtime-enhance-pcclasses"));
 }
 
+// this must be called under a proper locking, this is guaranteed by either
+// a correct concurrent classloader with transformation support OR
+// a mono-threaded access guarantee (build, deploy time enhancements).
 @Override
 public byte[] transform(ClassLoader loader, String className, Class redef, 
ProtectionDomain domain, byte[] bytes)
 throws IllegalClassFormatException {
@@ -116,17 +119,43 @@ public class PCClassFileTransformer
 if (className == null) {
 return null;
 }
-// prevent re-entrant calls, which can occur if the enhancing
-// loader is used to also load OpenJPA libraries; this is to prevent
-// recursive enhancement attempts for internal openjpa libraries
-if (_transforming)
-return null;
-
-_transforming = true;
 
 return transform0(className, redef, bytes);
 }
 
+// very simplified flavor of
+// @apache/tomee >
+// container/openejb-core >
+// org/apache/openejb/util/classloader/URLClassLoaderFirst.java#L207
+private boolean isExcluded(final String className) {
+if (// api
+className.startsWith("javax/") ||
+className.startsWith("jakarta/") ||
+// openjpa dependencies
+className.startsWith("serp/") ||
+// jvm
+className.startsWith("java/") ||
+className.startsWith("sun/") ||
+className.startsWith("jdk/")) {
+return true;
+}
+// it is faster to use substring when multiple tests are needed
+if (className.startsWith("org/apache/")) {
+final String sub = className.substring("org/apache/".length());
+if (sub.startsWith("openjpa/") ||
+sub.startsWith("commons/")) {
+return true;
+}
+}
+if (className.startsWith("com/")) {
+final String sub = className.substring("com/".length());
+if (sub.startsWith("oracle/") || sub.startsWith("sun/")) { // jvm
+return true;
+}
+}
+return false;
+}
+
 /**
  * We have to split the transform method into two methods to avoid
  * ClassCircularityError when executing method using pure-JIT JVMs
@@ -149,7 +178,7 @@ public class PCClassFileTransformer
 try {
 PCEnhancer enhancer = new PCEnhancer(_repos.getConfiguration(),
 new Project().loadClass(new 
ByteArrayInputStream(bytes),
-_tmpLoader), _repos);
+_tmpLoader), _repos, _tmpLoader);
 
enhancer.setAddDefaultConstructor(_flags.addDefaultConstructor);
 enhancer.setEnforcePropertyRestrictions
 (_flags.enforcePropertyRestrictions);
@@ -170,7 +199,6 @@ public class PCClassFileTransformer
 throw (IllegalClassFormatException) t;
 throw new GeneralException(t);
 } finally {
-_transforming = 

[openjpa] branch OPENJPA-2817_PCClassFileTransformer-exclusions updated (96b2b12 -> 9e665c0)

2020-07-23 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a change to branch 
OPENJPA-2817_PCClassFileTransformer-exclusions
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


from 96b2b12  excluding asm too
 add c933137  OPENJPA-2816 Add HerdDB DBDictionary - implement 
HerdDBDictionary - add autodiscovery of HerdDB
 add 0e32d49  Merge pull request #63 from eolivelli/fix/OPENJPA-2816-herddb
 add dcc313b  OPENJPA-2819 Add simple GitHub Actions validation for Pull 
Requests
 add 6ec962f  remove snapshots
 add c97bb58  hard code key cache
 add 6ddfe4e  add quotes
 add d4882b0  indent
 add 29ca489  better clause
 add 5263d8c  Switch to verify
 add 7822592  use 'package'
 add 80c7d3c  use 'install' goal
 add c1a6aa5  Merge pull request #70 from eolivelli/fix/OPENJPA-2819
 add e3bb1f1  OPENJPA-2818 DBDictionary > delimitIdentifiers = true does 
not work (#69)
 add 589d775  detect newer java versions as well
 add 5d9c88d  just fix broken javadoc
 add bf03bdb  OPENJPA-2822 get rid of tricks < java8
 add ab6e0ed  OPENJPA-2823 treat jakarta.* like javax.*
 add 94a033d  OPENJPA-2821 use AsmAdapter for subclassing
 add 5b81bea  use proper maven structure for persistence.xml
 add 093a547  Fix typo
 add 9e665c0  Merge branch 'master' into 
OPENJPA-2817_PCClassFileTransformer-exclusions

No new revisions were added by this update.

Summary of changes:
 .github/workflows/pr-validation.yml|  38 ++
 .../{java => resources}/META-INF/persistence.xml   |   0
 openjpa-jdbc/nbproject/project.properties  |   0
 .../openjpa/jdbc/conf/JDBCConfigurationImpl.java   |   1 +
 .../openjpa/jdbc/identifier/DBIdentifier.java  |  42 +-
 .../org/apache/openjpa/jdbc/schema/SchemaTool.java |   7 +-
 .../java/org/apache/openjpa/jdbc/schema/Table.java |  38 +-
 .../openjpa/jdbc/sql/DBDictionaryFactory.java  |   5 +-
 ...{CacheDictionary.java => HerdDBDictionary.java} |  37 +-
 .../org/apache/openjpa/jdbc/sql/SelectImpl.java|   6 +-
 .../openjpa/jdbc/sql/DBDictionaryFactoryTest.java  |  61 +++
 .../apache/openjpa/jdbc/sql/TestSelectImpl.java|  92 
 .../org/apache/openjpa/enhance/AsmAdaptor.java |  14 +
 .../org/apache/openjpa/enhance/ClassRedefiner.java |  44 +-
 .../openjpa/enhance/InstrumentationFactory.java|   9 -
 .../openjpa/enhance/ManagedClassSubclasser.java|   7 +-
 .../openjpa/enhance/PCClassFileTransformer.java|  32 +-
 .../org/apache/openjpa/lib/util/JavaVersions.java  |   6 +-
 .../openjpa/jdbc/sql/TestDelimitIdentifiers.java   | 536 +
 .../persistence/PersistenceProviderImpl.java   |   2 -
 .../src/doc/manual/ref_guide_dbsetup.xml   |  11 +
 21 files changed, 878 insertions(+), 110 deletions(-)
 create mode 100644 .github/workflows/pr-validation.yml
 rename openjpa-examples/simple/src/main/{java => 
resources}/META-INF/persistence.xml (100%)
 create mode 100644 openjpa-jdbc/nbproject/project.properties
 copy 
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/{CacheDictionary.java => 
HerdDBDictionary.java} (52%)
 create mode 100644 
openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactoryTest.java
 create mode 100644 
openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestSelectImpl.java
 create mode 100644 
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDelimitIdentifiers.java



[openjpa] branch master updated: Fix typo

2020-07-23 Thread ilgrosso
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
 new 093a547  Fix typo
093a547 is described below

commit 093a547193e0e2b85c737d409e5808c7dafe271a
Author: Francesco Chicchiriccò 
AuthorDate: Thu Jul 23 14:53:53 2020 +0200

Fix typo
---
 openjpa-examples/simple/src/main/resources/META-INF/persistence.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/openjpa-examples/simple/src/main/resources/META-INF/persistence.xml 
b/openjpa-examples/simple/src/main/resources/META-INF/persistence.xml
index 9a27b9f..694473e 100644
--- a/openjpa-examples/simple/src/main/resources/META-INF/persistence.xml
+++ b/openjpa-examples/simple/src/main/resources/META-INF/persistence.xml
@@ -1,4 +1,4 @@
-d
+
 

[openjpa] branch master updated: use proper maven structure for persistence.xml

2020-07-23 Thread struberg
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/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
 new 5b81bea  use proper maven structure for persistence.xml
5b81bea is described below

commit 5b81bead84f834b283f171d0e29166cda565a8f9
Author: Mark Struberg 
AuthorDate: Thu Jul 23 14:51:31 2020 +0200

use proper maven structure for persistence.xml
---
 .../simple/src/main/{java => resources}/META-INF/persistence.xml| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/openjpa-examples/simple/src/main/java/META-INF/persistence.xml 
b/openjpa-examples/simple/src/main/resources/META-INF/persistence.xml
similarity index 99%
rename from openjpa-examples/simple/src/main/java/META-INF/persistence.xml
rename to openjpa-examples/simple/src/main/resources/META-INF/persistence.xml
index 694473e..9a27b9f 100644
--- a/openjpa-examples/simple/src/main/java/META-INF/persistence.xml
+++ b/openjpa-examples/simple/src/main/resources/META-INF/persistence.xml
@@ -1,4 +1,4 @@
-
+d
 

[openjpa] branch master updated (e3bb1f1 -> 94a033d)

2020-07-23 Thread struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


from e3bb1f1  OPENJPA-2818 DBDictionary > delimitIdentifiers = true does 
not work (#69)
 new 589d775  detect newer java versions as well
 new 5d9c88d  just fix broken javadoc
 new bf03bdb  OPENJPA-2822 get rid of tricks < java8
 new ab6e0ed  OPENJPA-2823 treat jakarta.* like javax.*
 new 94a033d  OPENJPA-2821 use AsmAdapter for subclassing

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/openjpa/enhance/AsmAdaptor.java | 14 +++
 .../org/apache/openjpa/enhance/ClassRedefiner.java | 44 ++
 .../openjpa/enhance/InstrumentationFactory.java|  9 -
 .../openjpa/enhance/ManagedClassSubclasser.java|  7 +++-
 .../openjpa/enhance/PCClassFileTransformer.java| 26 ++---
 .../org/apache/openjpa/lib/util/JavaVersions.java  |  6 ++-
 .../persistence/PersistenceProviderImpl.java   |  2 -
 7 files changed, 49 insertions(+), 59 deletions(-)



[openjpa] 02/05: just fix broken javadoc

2020-07-23 Thread struberg
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/openjpa.git

commit 5d9c88d7cbcc3cdfba0e9fee9d5c6b37bba08030
Author: Mark Struberg 
AuthorDate: Thu Jul 23 13:48:25 2020 +0200

just fix broken javadoc
---
 .../java/org/apache/openjpa/persistence/PersistenceProviderImpl.java| 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
index 0b6d998..9d24553 100644
--- 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
+++ 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
@@ -373,8 +373,6 @@ public class PersistenceProviderImpl
  * This private worker method will attempt to setup the proper
  * LifecycleEventManager type based on if the javax.validation APIs are
  * available and a ValidatorImpl is required by the configuration.
- * @param log
- * @param conf
  * @throws if validation setup failed and was required by the config
  */
 private void loadValidator(BrokerFactory factory) {



[openjpa] 01/05: detect newer java versions as well

2020-07-23 Thread struberg
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/openjpa.git

commit 589d7755d2711198d7f38fd79d14e61b778a2118
Author: Mark Struberg 
AuthorDate: Thu Jul 23 13:47:27 2020 +0200

detect newer java versions as well
---
 .../src/main/java/org/apache/openjpa/lib/util/JavaVersions.java | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVersions.java 
b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVersions.java
index 9963ebb..ae402e5 100644
--- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVersions.java
+++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVersions.java
@@ -53,8 +53,12 @@ public class JavaVersions {
 VERSION = 5;
 else if ("1.6".equals(specVersion))
 VERSION = 6;
+else if ("1.7".equals(specVersion))
+VERSION = 7;
+else if ("1.8".equals(specVersion))
+VERSION = 8;
 else
-VERSION = 7; // maybe someday...
+VERSION = 9; // maybe someday...
 }
 
 /**



[openjpa] 04/05: OPENJPA-2823 treat jakarta.* like javax.*

2020-07-23 Thread struberg
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/openjpa.git

commit ab6e0ed4b46f7e3ef59c8ab74b3e9de4fdeff8b9
Author: Mark Struberg 
AuthorDate: Thu Jul 23 14:04:44 2020 +0200

OPENJPA-2823 treat jakarta.* like javax.*

also simplify needsEnhance logic
---
 .../openjpa/enhance/PCClassFileTransformer.java| 26 ++
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
index 872d413..d67fb48 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
@@ -64,8 +64,7 @@ public class PCClassFileTransformer
  * @param opts enhancer configuration options
  * @param loader temporary class loader for loading intermediate classes
  */
-public PCClassFileTransformer(MetaDataRepository repos, Options opts,
-ClassLoader loader) {
+public PCClassFileTransformer(MetaDataRepository repos, Options opts, 
ClassLoader loader) {
 this(repos, toFlags(opts), loader, opts.removeBooleanProperty
 ("scanDevPath", "ScanDevPath", false));
 }
@@ -93,8 +92,7 @@ public class PCClassFileTransformer
  * @param devscan whether to scan the dev classpath for persistent types
  * if none are configured
  */
-public PCClassFileTransformer(MetaDataRepository repos,
-PCEnhancer.Flags flags, ClassLoader tmpLoader, boolean devscan) {
+public PCClassFileTransformer(MetaDataRepository repos, PCEnhancer.Flags 
flags, ClassLoader tmpLoader, boolean devscan) {
 _repos = repos;
 _tmpLoader = tmpLoader;
 
@@ -108,9 +106,9 @@ public class PCClassFileTransformer
 }
 
 @Override
-public byte[] transform(ClassLoader loader, String className,
-Class redef, ProtectionDomain domain, byte[] bytes)
+public byte[] transform(ClassLoader loader, String className, Class redef, 
ProtectionDomain domain, byte[] bytes)
 throws IllegalClassFormatException {
+
 if (loader == _tmpLoader)
 return null;
 
@@ -183,12 +181,9 @@ public class PCClassFileTransformer
  * Return whether the given class needs enhancement.
  */
 private Boolean needsEnhance(String clsName, Class redef, byte[] bytes) {
-if (redef != null) {
-Class[] intfs = redef.getInterfaces();
-for (int i = 0; i < intfs.length; i++)
-if (PersistenceCapable.class.getName().
-equals(intfs[i].getName()))
-return Boolean.valueOf(!isEnhanced(bytes));
+if (redef != null && PersistenceCapable.class.isAssignableFrom(redef)) 
{
+// if the original class is already enhanced (implements 
PersistenceCapable)
+// then we don't need to do any further processing.
 return null;
 }
 
@@ -198,10 +193,13 @@ public class PCClassFileTransformer
 return null;
 }
 
-if (clsName.startsWith("java/") || clsName.startsWith("javax/"))
+if (clsName.startsWith("java/") || clsName.startsWith("javax/") || 
clsName.startsWith("jakarta/")) {
 return null;
-if (isEnhanced(bytes))
+}
+
+if (isEnhanced(bytes)) {
 return Boolean.FALSE;
+}
 
 try {
 Class c = Class.forName(clsName.replace('/', '.'), false,



[openjpa] 03/05: OPENJPA-2822 get rid of tricks < java8

2020-07-23 Thread struberg
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/openjpa.git

commit bf03bdb314d99502046543e2e904235f87f46bb3
Author: Mark Struberg 
AuthorDate: Thu Jul 23 14:00:10 2020 +0200

OPENJPA-2822 get rid of tricks < java8

we can now rely on transform() being available on all JVMs.
---
 .../org/apache/openjpa/enhance/ClassRedefiner.java | 44 ++
 .../openjpa/enhance/InstrumentationFactory.java|  9 -
 2 files changed, 12 insertions(+), 41 deletions(-)

diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
index 339dc2e..0b2e11e 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
@@ -18,10 +18,8 @@
  */
 package org.apache.openjpa.enhance;
 
-import java.lang.instrument.ClassDefinition;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.Instrumentation;
-import java.lang.reflect.Method;
 import java.security.ProtectionDomain;
 import java.util.Map;
 
@@ -47,7 +45,7 @@ public class ClassRedefiner {
 /**
  * For each element in classes, this method will redefine
  * all the element's methods such that field accesses are intercepted
- * in-line. If {@link #canRedefineClasses()} returns false,
+ * in-line. If {@link #canRedefineClasses(Log)} returns false,
  * this method is a no-op.
  */
 public static void redefineClasses(OpenJPAConfiguration conf,
@@ -62,37 +60,19 @@ public class ClassRedefiner {
 inst = InstrumentationFactory.getInstrumentation(log);
 
 Class[] array = classes.keySet().toArray(new 
Class[classes.size()]);
-if (JavaVersions.VERSION >= 6) {
-log.trace(_loc.get("retransform-types", classes.keySet()));
+log.trace(_loc.get("retransform-types", classes.keySet()));
 
-t = new ClassFileTransformer() {
-@Override
-public byte[] transform(ClassLoader loader, String clsName,
-Class classBeingRedefined, ProtectionDomain pd,
-byte[] classfileBuffer) {
-return classes.get(classBeingRedefined);
-}
-};
+t = new ClassFileTransformer() {
+@Override
+public byte[] transform(ClassLoader loader, String clsName,
+Class classBeingRedefined, ProtectionDomain pd,
+byte[] classfileBuffer) {
+return classes.get(classBeingRedefined);
+}
+};
 
-// these are Java 6 methods, and we don't have a Java 6 build
-// module yet. The cost of reflection here is negligible
-// compared to the redefinition / enhancement costs in total,
-// so this should not be a big problem.
-Method meth = inst.getClass().getMethod("addTransformer",
-new Class[] { ClassFileTransformer.class, boolean.class });
-meth.invoke(inst, new Object[] { t, true });
-meth = inst.getClass().getMethod("retransformClasses",
-new Class[] { array.getClass() });
-meth.invoke(inst, new Object[] { array });
-} else {
-log.trace(_loc.get("redefine-types", classes.keySet()));
-// in a Java 5 context, we can use class redefinition instead
-ClassDefinition[] defs = new ClassDefinition[array.length];
-for (int i = 0; i < defs.length; i++)
-defs[i] = new ClassDefinition(array[i],
-classes.get(array[i]));
-inst.redefineClasses(defs);
-}
+inst.addTransformer(t, true);
+inst.retransformClasses(array);
 } catch (Exception e) {
 throw new InternalException(e);
 } finally {
diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
index feeb982..3516750 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
@@ -40,7 +40,6 @@ import java.util.zip.ZipOutputStream;
 
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.JavaVendors;
-import org.apache.openjpa.lib.util.JavaVersions;
 import org.apache.openjpa.lib.util.Localizer;
 
 
@@ -89,14 +88,6 @@ public class InstrumentationFactory {
 if ( _inst != null || !_dynamicallyInstall)
 

[openjpa] 05/05: OPENJPA-2821 use AsmAdapter for subclassing

2020-07-23 Thread struberg
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/openjpa.git

commit 94a033d83bcab3e8f00c9927533ae9889c3d11ec
Author: Mark Struberg 
AuthorDate: Thu Jul 23 14:05:56 2020 +0200

OPENJPA-2821 use AsmAdapter for subclassing

to write proper java8 code
---
 .../main/java/org/apache/openjpa/enhance/AsmAdaptor.java   | 14 ++
 .../org/apache/openjpa/enhance/ManagedClassSubclasser.java |  7 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/AsmAdaptor.java 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/AsmAdaptor.java
index 7bef1ef..6bb26d9 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/AsmAdaptor.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/AsmAdaptor.java
@@ -81,6 +81,20 @@ public final class AsmAdaptor {
 }
 }
 
+public static void write(BCClass bc, OutputStream os) throws IOException {
+if (bc.getMajorVersion() < Java7_MajorVersion) {
+bc.write(os);
+}
+else {
+try {
+writeJava7(bc, os);
+} finally {
+os.flush();
+os.close();
+}
+}
+}
+
 public static byte[] toByteArray(BCClass bc, byte[] returnBytes) throws 
IOException {
 if (bc.getMajorVersion() >= Java7_MajorVersion) {
 returnBytes = toJava7ByteArray(bc, returnBytes);
diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
index fab02ab..0a7d376 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.enhance;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -142,6 +143,8 @@ public class ManagedClassSubclasser {
 if (redefine) {
 enhancer.setRedefine(true);
 }
+
+// we need to create subclasses because class retransform doesn't 
allow to change the interfaces of a previously loaded class
 enhancer.setCreateSubclass(true);
 enhancer.setAddDefaultConstructor(true);
 
@@ -276,7 +279,9 @@ public class ManagedClassSubclasser {
 if (enhancer.isAlreadyRedefined())
 ints.add(bc.getType());
 else {
-map.put(bc.getType(), bc.toByteArray());
+ByteArrayOutputStream baos = new ByteArrayOutputStream();
+AsmAdaptor.write(bc, baos);
+map.put(bc.getType(), baos.toByteArray());
 debugBytecodes(bc);
 }
 } else {



[openjpa] annotated tag 3.1.1 created (now e7d6f56)

2020-07-23 Thread struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a change to annotated tag 3.1.1
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


  at e7d6f56  (tag)
 tagging 1440702eec4ee0167b16606592198356765f4082 (commit)
 replaces 3.1.0
  by Mark Struberg
  on Fri Feb 14 12:12:11 2020 +0100

- Log -
[maven-release-plugin] copy for tag 3.1.1
---

No new revisions were added by this update.



[openjpa] annotated tag 3.1.2 created (now 9fc9627)

2020-07-23 Thread struberg
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a change to annotated tag 3.1.2
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


  at 9fc9627  (tag)
 tagging 66d2a72cb2252a59086d76983979b6512c887a3b (commit)
 replaces 3.1.0
  by Mark Struberg
  on Tue Jul 7 11:19:15 2020 +0200

- Log -
[maven-release-plugin] copy for tag 3.1.2
---

No new revisions were added by this update.