diff --git a/.travis.yml b/.travis.yml
index c55a51ebac..6846a084f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,8 @@ cache:
before_install:
- sh -c "if [ '$RDBMS' = 'firebird' ]; then sh travis/before_install_firebird.sh; fi"
install:
- - sh -c "if [ '$LATEST_MAVEN' = 'true' ]; then sh travis/install_latest_maven.sh; fi"
+# Skip the first maven execution for downloading dependencies by using this command
+ - /bin/true
before_script:
- sh -c "if [ '$RDBMS' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS test DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_bin;'; fi"
- sh -c "if [ '$RDBMS' = 'postgresql' ]; then psql -c 'create database test;' -U postgres; fi"
@@ -402,128 +403,94 @@ matrix:
################################################
# JDK 9+
################################################
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 LATEST_MAVEN=true
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 10 -L GPL
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 LATEST_MAVEN=true
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 11 -L BCL
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10 LATEST_MAVEN=true
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 10 -L GPL
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11 LATEST_MAVEN=true
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11
before_install:
- wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
- . ./install-jdk.sh -F 11 -L BCL
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true
- addons:
- apt:
- packages:
- - oracle-java9-installer
- jdk: oraclejdk9
- - env: JPAPROVIDER=datanucleus-5 RDBMS=h2 JDK=9 LATEST_MAVEN=true
- addons:
- apt:
- packages:
- - oracle-java9-installer
- jdk: oraclejdk9
- - env: JPAPROVIDER=eclipselink RDBMS=h2 JDK=9 LATEST_MAVEN=true
- addons:
- apt:
- packages:
- - oracle-java9-installer
- jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9
+ before_install:
+ - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+ - . ./install-jdk.sh -F 9 -L GPL
+ - env: JPAPROVIDER=datanucleus-5 RDBMS=h2 JDK=9
+ before_install:
+ - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+ - . ./install-jdk.sh -F 9 -L GPL
+ - env: JPAPROVIDER=eclipselink RDBMS=h2 JDK=9
+ before_install:
+ - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+ - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
################################################
# Skip JDK 9 profile combinations for older JPA provider versions
################################################
-# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
+# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
allow_failures:
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10 LATEST_MAVEN=true
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11 LATEST_MAVEN=true
- - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 LATEST_MAVEN=true
-# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
-# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9 LATEST_MAVEN=true
-# addons:
-# apt:
-# packages:
-# - oracle-java9-installer
-# jdk: oraclejdk9
\ No newline at end of file
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 BUILD_JDK=10
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11 BUILD_JDK=11
+ - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=11
+# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
+# - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9
+# before_install:
+# - wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
+# - . ./install-jdk.sh -F 9 -L GPL
\ No newline at end of file
diff --git a/README.md b/README.md
index 64ffad8f60..3567b704e2 100644
--- a/README.md
+++ b/README.md
@@ -570,6 +570,15 @@ Setup local development
Here some notes about setting up a local environment for testing.
+## Setup general build environment
+
+Although Blaze-Persistence still supports running on Java 7, the build must be run with at least JDK 8.
+When doing a release at least a JDK 9 is required as we need to build some Multi-Release or MR JARs.
+Since we try to support the latest JDK versions as well, we require developers that want to build the project with JDK 11+ to define a system property.
+
+The system property `jdk8.home` should be set to the path to a Java 7 or 8 installation that contains either `jre/lib/rt.jar` or `jre/lib/classes.jar`.
+This property is necessary when using JDK 11+ because `sun.misc.Unsafe.defineClass` was removed.
+
## Building the website and documentation
You have to install [GraphViz](http://www.graphviz.org/Download.php) and make it available in your PATH.
diff --git a/build.sh b/build.sh
index d2c9d67815..78c7369e05 100755
--- a/build.sh
+++ b/build.sh
@@ -1,14 +1,18 @@
#!/bin/bash
set -e
+set -x
+
+SOURCE="${BASH_SOURCE[0]}"
+while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+ SOURCE="$(readlink "$SOURCE")"
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+done
+DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$JDK" != "" ]; then
- MVN_BIN=/tmp/apache-maven/bin/mvn
- export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m" # --add-modules=java.se.ee"
-elif [ "$LATEST_MAVEN" = "true" ]; then
- MVN_BIN=/tmp/apache-maven/bin/mvn
export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m" # --add-modules=java.se.ee"
else
- MVN_BIN=mvn
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m"
fi
@@ -16,19 +20,23 @@ if [ "$JDK" = "9" ]; then
export JAVA_HOME="/usr/lib/jvm/java-9-oracle/"
fi
-${MVN_BIN} -version
+mvn -version
PROPERTIES="$PROPERTIES -Duser.country=US -Duser.language=en"
if [ "$BUILD_JDK" != "" ]; then
- PROPERTIES="$PROPERTIES -Dmaven.compiler.target=$BUILD_JDK -Dmaven.compiler.source=$BUILD_JDK"
+ PROPERTIES="$PROPERTIES -Djava.version=$BUILD_JDK"
+fi
+
+if [ "$JDK" != "" ]; then
+ PROPERTIES="$PROPERTIES -Djdk8.home=/usr/lib/jvm/java-8-oracle"
fi
if [ "$TRAVIS_REPO_SLUG" == "Blazebit/blaze-persistence" ] &&
[ "$TRAVIS_BRANCH" == "master" ] &&
[ "$JPAPROVIDER" == "hibernate-5.2" ] &&
[ "$RDBMS" == "h2" ]; then
- exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} install
+ exec mvn -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} clean install -V $PROPERTIES
else
if [ "$TRAVIS_REPO_SLUG" == "Blazebit/blaze-persistence" ] &&
[ "$TRAVIS_BRANCH" == "master" ] &&
@@ -42,5 +50,5 @@ else
: # do nothing right now
fi
- eval exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} install --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite,integration/deltaspike-data/testsuite,integration/spring-data/testsuite,examples/spring-data-rest,examples/showcase/runner/spring,examples/showcase/runner/cdi" -am $PROPERTIES
+ eval exec mvn -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} clean install --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite,integration/deltaspike-data/testsuite,integration/spring-data/testsuite,examples/spring-data-rest,examples/showcase/runner/spring,examples/showcase/runner/cdi" -am -V $PROPERTIES
fi
diff --git a/core/api/pom.xml b/core/api/pom.xml
index d3c8da3cdc..703f1b63fd 100644
--- a/core/api/pom.xml
+++ b/core/api/pom.xml
@@ -42,4 +42,102 @@
provided
+
+
+
+
+ org.moditect
+ moditect-maven-plugin
+
+
+ add-module-infos
+ post-package
+
+ add-module-info
+
+
+ ${project.version}-module
+
+
+ module ${module.name} {
+ requires transitive java.sql;
+ requires transitive java.persistence;
+ exports com.blazebit.persistence;
+ exports com.blazebit.persistence.spi;
+ exports com.blazebit.persistence.internal;
+ uses com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider;
+ }
+
+
+
+
+
+
+
+
+
+
+
+ java9
+
+ [1.9,)
+
+
+ src/main/java9
+
+
+
+
+ maven-antrun-plugin
+
+
+ compile-java9
+ compile
+
+
+
+
+
+
+
+ run
+
+
+
+
+
+ maven-jar-plugin
+ true
+
+
+
+ true
+
+
+
+
+
+ default-jar
+ package
+
+ jar
+
+
+
+ modular-jar
+ package
+
+ jar
+
+
+ module
+
+
+
+
+
+
+
+
diff --git a/core/api/src/main/java/com/blazebit/persistence/Criteria.java b/core/api/src/main/java/com/blazebit/persistence/Criteria.java
index 7d25dbcb04..0d31dbaa1d 100644
--- a/core/api/src/main/java/com/blazebit/persistence/Criteria.java
+++ b/core/api/src/main/java/com/blazebit/persistence/Criteria.java
@@ -56,6 +56,6 @@ public static CriteriaBuilderConfigurationProvider getDefaultProvider() {
* @return A new criteria builder configuration
*/
public static CriteriaBuilderConfiguration getDefault() {
- return getDefaultProvider().createConfiguration();
+ return getDefaultProvider().createConfiguration(DefaultPackageOpener.INSTANCE);
}
}
diff --git a/core/api/src/main/java/com/blazebit/persistence/DefaultPackageOpener.java b/core/api/src/main/java/com/blazebit/persistence/DefaultPackageOpener.java
new file mode 100644
index 0000000000..5b69f4e13f
--- /dev/null
+++ b/core/api/src/main/java/com/blazebit/persistence/DefaultPackageOpener.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 - 2018 Blazebit.
+ *
+ * Licensed 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 com.blazebit.persistence;
+
+import com.blazebit.persistence.spi.PackageOpener;
+
+/**
+ * A no-op package opener for pre-Java 9.
+ *
+ * @author Christian Beikov
+ * @since 1.2.0
+ */
+class DefaultPackageOpener implements PackageOpener {
+
+ static final PackageOpener INSTANCE = new DefaultPackageOpener();
+
+ private DefaultPackageOpener() {
+ }
+
+ @Override
+ public void openPackageIfNeeded(Class> targetClass, String targetPackage, Class> implementationClass) {
+ }
+}
diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfiguration.java b/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfiguration.java
index b02d4750ac..02531e380f 100644
--- a/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfiguration.java
+++ b/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfiguration.java
@@ -32,6 +32,15 @@
*/
public interface CriteriaBuilderConfiguration {
+ /**
+ * Sets the package opener to use for obtaining access to user classes.
+ *
+ * @param packageOpener The package opener to use to obtain access to user classes
+ * @return this for method chaining
+ * @since 1.2.0
+ */
+ public CriteriaBuilderConfiguration withPackageOpener(PackageOpener packageOpener);
+
/**
* Registers the given type under the given name. This makes the type usable for the VALUES
clause.
*
diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java b/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java
index ceb9d01f6f..186ff91e02 100644
--- a/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java
+++ b/core/api/src/main/java/com/blazebit/persistence/spi/CriteriaBuilderConfigurationProvider.java
@@ -32,4 +32,13 @@ public interface CriteriaBuilderConfigurationProvider {
* @return A new criteria builder configuration
*/
public CriteriaBuilderConfiguration createConfiguration();
+
+ /**
+ * Creates and returns a new criteria builder configuration.
+ *
+ * @param packageOpener The package opener to use to obtain access to user classes
+ * @return A new criteria builder configuration
+ * @since 1.2.0
+ */
+ public CriteriaBuilderConfiguration createConfiguration(PackageOpener packageOpener);
}
diff --git a/core/api/src/main/java/com/blazebit/persistence/spi/PackageOpener.java b/core/api/src/main/java/com/blazebit/persistence/spi/PackageOpener.java
new file mode 100644
index 0000000000..ca3bcbcf02
--- /dev/null
+++ b/core/api/src/main/java/com/blazebit/persistence/spi/PackageOpener.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 - 2018 Blazebit.
+ *
+ * Licensed 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 com.blazebit.persistence.spi;
+
+/**
+ * A package opener can be used to propagate module visibilities.
+ *
+ * @author Christian Beikov
+ * @since 1.2.0
+ */
+public interface PackageOpener {
+
+ /**
+ * A no-op package opener.
+ */
+ public static final PackageOpener NOOP = new PackageOpener() {
+ @Override
+ public void openPackageIfNeeded(Class> targetClass, String targetPackage, Class> implementationClass) {
+ }
+ };
+
+ /**
+ * Opens the given package of the module of the target class to the module of the implementation class.
+ *
+ * @param targetClass The class by which to obtain the module that should be opened.
+ * @param targetPackage The package of the module that should be opened.
+ * @param implementationClass The class by which to obtain the module to which the given package should be opened.
+ */
+ public void openPackageIfNeeded(Class> targetClass, String targetPackage, Class> implementationClass);
+}
diff --git a/core/api/src/main/java9/com/blazebit/persistence/DefaultPackageOpener.java b/core/api/src/main/java9/com/blazebit/persistence/DefaultPackageOpener.java
new file mode 100644
index 0000000000..f80e6e609d
--- /dev/null
+++ b/core/api/src/main/java9/com/blazebit/persistence/DefaultPackageOpener.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014 - 2018 Blazebit.
+ *
+ * Licensed 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 com.blazebit.persistence;
+
+import com.blazebit.persistence.spi.PackageOpener;
+
+/**
+ * A package opener that works with Java 9 modules.
+ *
+ * @author Christian Beikov
+ * @since 1.2.0
+ */
+class DefaultPackageOpener implements PackageOpener {
+
+ static final PackageOpener INSTANCE = new DefaultPackageOpener();
+
+ private DefaultPackageOpener() {
+ }
+
+ @Override
+ public void openPackageIfNeeded(Class> targetClass, String targetPackage, Class> implementationClass) {
+ Module targetModule = targetClass.getModule();
+ if (!targetModule.isOpen(targetPackage, implementationClass.getModule())) {
+ targetModule.addOpens(targetPackage, implementationClass.getModule());
+ }
+ }
+}
diff --git a/core/impl/pom.xml b/core/impl/pom.xml
index cb87fba6a4..649633de5a 100644
--- a/core/impl/pom.xml
+++ b/core/impl/pom.xml
@@ -100,7 +100,103 @@
+
+ org.moditect
+ moditect-maven-plugin
+
+
+ add-module-infos
+ post-package
+
+ add-module-info
+
+
+ ${project.version}-module
+
+
+ module ${module.name} {
+ requires java.sql;
+ requires java.persistence;
+ requires com.blazebit.common.utils;
+ requires com.blazebit.persistence.core;
+ requires com.blazebit.persistence.core.parser;
+ exports com.blazebit.persistence.impl;
+ uses com.blazebit.persistence.spi.EntityManagerFactoryIntegrator;
+ uses com.blazebit.persistence.spi.ExtendedQuerySupport;
+ provides com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider with com.blazebit.persistence.impl.CriteriaBuilderConfigurationProviderImpl;
+ }
+
+
+
+
+
+
+
+
+ java9
+
+ [1.9,)
+
+
+ src/main/java9
+
+
+
+
+ maven-antrun-plugin
+
+
+ compile-java9
+ compile
+
+
+
+
+
+
+
+ run
+
+
+
+
+
+ maven-jar-plugin
+ true
+
+
+
+ true
+
+
+
+
+
+ default-jar
+ package
+
+ jar
+
+
+
+ modular-jar
+ package
+
+ jar
+
+
+ module
+
+
+
+
+
+
+
+
+
diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CallerChecker.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CallerChecker.java
new file mode 100644
index 0000000000..253e0564c8
--- /dev/null
+++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CallerChecker.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 - 2018 Blazebit.
+ *
+ * Licensed 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 com.blazebit.persistence.impl;
+
+/**
+ * A contract that checks if the caller of our caller is trusted. On Java 9 this will actually check modules.
+ *
+ * @author Christian Beikov
+ * @since 1.2.0
+ */
+class CallerChecker {
+
+ private CallerChecker() {
+ }
+
+ public static boolean isCallerTrusted() {
+ return true;
+ }
+}
diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationImpl.java
index 3c4310524e..a79a24e9f4 100644
--- a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationImpl.java
+++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationImpl.java
@@ -150,6 +150,7 @@
import com.blazebit.persistence.spi.ExtendedQuerySupport;
import com.blazebit.persistence.spi.JpqlFunctionGroup;
import com.blazebit.persistence.spi.JpqlMacro;
+import com.blazebit.persistence.spi.PackageOpener;
import com.blazebit.persistence.spi.SetOperationType;
import javax.persistence.EntityManagerFactory;
@@ -180,10 +181,12 @@ public class CriteriaBuilderConfigurationImpl implements CriteriaBuilderConfigur
private final Map> treatTypes = new HashMap>();
private final Map macros = new HashMap();
private final List entityManagerIntegrators = new ArrayList();
+ private PackageOpener packageOpener;
private Properties properties = new Properties();
private ExtendedQuerySupport extendedQuerySupport;
- public CriteriaBuilderConfigurationImpl() {
+ public CriteriaBuilderConfigurationImpl(PackageOpener packageOpener) {
+ this.packageOpener = packageOpener;
loadDefaultProperties();
loadExtendedQuerySupport();
loadEntityManagerIntegrator();
@@ -525,6 +528,16 @@ private void loadEntityManagerIntegrator() {
}
}
+ @Override
+ public CriteriaBuilderConfiguration withPackageOpener(PackageOpener packageOpener) {
+ this.packageOpener = packageOpener;
+ return this;
+ }
+
+ PackageOpener getPackageOpener() {
+ return packageOpener;
+ }
+
@Override
public CriteriaBuilderConfiguration registerFunction(JpqlFunctionGroup jpqlFunctionGroup) {
String functionName = jpqlFunctionGroup.getName().toLowerCase();
diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java
index c0409853a3..5c3d6ce69f 100644
--- a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java
+++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderConfigurationProviderImpl.java
@@ -20,6 +20,7 @@
import com.blazebit.persistence.spi.CriteriaBuilderConfiguration;
import com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider;
+import com.blazebit.persistence.spi.PackageOpener;
/**
*
@@ -33,12 +34,17 @@ public class CriteriaBuilderConfigurationProviderImpl implements CriteriaBuilder
@Override
public CriteriaBuilderConfiguration createConfiguration() {
+ return createConfiguration(PackageOpener.NOOP);
+ }
+
+ @Override
+ public CriteriaBuilderConfiguration createConfiguration(PackageOpener packageOpener) {
if (!versionLogged) {
LOG.info("Blaze-Persistence version: " + Version.printVersion());
versionLogged = true;
}
- return new CriteriaBuilderConfigurationImpl();
+ return new CriteriaBuilderConfigurationImpl(packageOpener);
}
}
diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderFactoryImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderFactoryImpl.java
index 34a9bce968..224f075b8e 100644
--- a/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderFactoryImpl.java
+++ b/core/impl/src/main/java/com/blazebit/persistence/impl/CriteriaBuilderFactoryImpl.java
@@ -37,6 +37,7 @@
import com.blazebit.persistence.spi.JpaProviderFactory;
import com.blazebit.persistence.spi.JpqlFunction;
import com.blazebit.persistence.spi.JpqlFunctionGroup;
+import com.blazebit.persistence.spi.PackageOpener;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -55,6 +56,7 @@
*/
public class CriteriaBuilderFactoryImpl implements CriteriaBuilderFactory {
+ private final PackageOpener packageOpener;
private final EntityManagerFactory entityManagerFactory;
private final EntityMetamodelImpl metamodel;
private final AssociationParameterTransformerFactory transientEntityParameterTransformerFactory;
@@ -93,6 +95,7 @@ public CriteriaBuilderFactoryImpl(CriteriaBuilderConfigurationImpl config, Entit
dialect = dbmsDialects.get(null);
}
+ this.packageOpener = config.getPackageOpener();
this.configuredDbms = dbms;
this.configuredDbmsDialect = dialect;
this.configuredRegisteredFunctions = registeredFunctions;
@@ -329,6 +332,10 @@ public T getService(Class serviceClass) {
return (T) metamodel;
} else if (EntityManagerFactory.class.equals(serviceClass)) {
return (T) entityManagerFactory;
+ } else if (PackageOpener.class.equals(serviceClass)) {
+ if (CallerChecker.isCallerTrusted()) {
+ return (T) packageOpener;
+ }
}
return null;
diff --git a/core/impl/src/main/java9/com/blazebit/persistence/impl/CallerChecker.java b/core/impl/src/main/java9/com/blazebit/persistence/impl/CallerChecker.java
new file mode 100644
index 0000000000..52ce6c4333
--- /dev/null
+++ b/core/impl/src/main/java9/com/blazebit/persistence/impl/CallerChecker.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2014 - 2018 Blazebit.
+ *
+ * Licensed 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 com.blazebit.persistence.impl;
+
+import java.util.Set;
+
+/**
+ * A contract that checks if the caller of our caller is trusted. On Java 9 this will actually check modules.
+ *
+ * @author Christian Beikov
+ * @since 1.2.0
+ */
+class CallerChecker {
+
+ private CallerChecker() {
+ }
+
+ public static boolean isCallerTrusted() {
+ return StackWalker.getInstance(Set.of(), 2).walk(stackFrames -> {
+ return stackFrames.limit(2).allMatch(s -> s.getClassName().startsWith("com.blazebit.persistence."));
+ });
+ }
+}
diff --git a/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider b/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider
index c0068cec27..85dfde3292 100644
--- a/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider
+++ b/core/impl/src/main/resources/META-INF/services/com.blazebit.persistence.spi.CriteriaBuilderConfigurationProvider
@@ -14,86 +14,4 @@
# limitations under the License.
#
-#
-# Copyright 2014 - 2018 Blazebit.
-#
-# Licensed 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.
-#
-
-#
-# Copyright 2014 - 2018 Blazebit.
-#
-# Licensed 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.
-#
-
-#
-# Copyright 2014 - 2018 Blazebit.
-#
-# Licensed 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.
-#
-
-#
-# Copyright 2014 - 2018 Blazebit.
-#
-# Licensed 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.
-#
-
-#
-# /*
-# * Copyright 2014 - 2018 Blazebit.
-# *
-# * Licensed 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.
-# */
-#
-
com.blazebit.persistence.impl.CriteriaBuilderConfigurationProviderImpl
diff --git a/core/parser/pom.xml b/core/parser/pom.xml
index 4b494c1dd5..8f72e5c86a 100644
--- a/core/parser/pom.xml
+++ b/core/parser/pom.xml
@@ -113,6 +113,36 @@
+
+ org.moditect
+ moditect-maven-plugin
+
+
+ add-module-infos
+ package
+
+ add-module-info
+
+
+ ${project.version}-module
+
+
+ module ${module.name} {
+ requires java.sql;
+ requires java.persistence;
+ requires org.antlr.antlr4.runtime;
+ requires com.blazebit.common.utils;
+ exports com.blazebit.persistence.parser;
+ exports com.blazebit.persistence.parser.expression;
+ exports com.blazebit.persistence.parser.predicate;
+ exports com.blazebit.persistence.parser.util;
+ }
+
+
+
+
+
+
diff --git a/core/testsuite/pom.xml b/core/testsuite/pom.xml
index fee691d2aa..16b2195d4f 100644
--- a/core/testsuite/pom.xml
+++ b/core/testsuite/pom.xml
@@ -97,6 +97,43 @@
+
+
+
+ org.moditect
+ moditect-maven-plugin
+
+
+ add-module-infos
+ package
+
+ add-module-info
+
+
+ ${project.version}-module
+
+
+ open module ${module.name} {
+ requires java.sql;
+ requires java.persistence;
+ requires com.blazebit.common.utils;
+ requires com.blazebit.persistence.core;
+ requires com.blazebit.persistence.core.parser;
+ requires com.blazebit.persistence.core.impl;
+ exports com.blazebit.persistence.testsuite;
+ exports com.blazebit.persistence.testsuite.entity;
+ exports com.blazebit.persistence.testsuite.treat.entity;
+ exports com.blazebit.persistence.testsuite.tx;
+ }
+
+
+
+
+
+
+
+
+
diff --git a/core/testsuite/src/main/java/com/blazebit/persistence/testsuite/entity/Version.java b/core/testsuite/src/main/java/com/blazebit/persistence/testsuite/entity/Version.java
index 7c2bf62bdd..67cbf1a969 100644
--- a/core/testsuite/src/main/java/com/blazebit/persistence/testsuite/entity/Version.java
+++ b/core/testsuite/src/main/java/com/blazebit/persistence/testsuite/entity/Version.java
@@ -47,6 +47,13 @@ public class Version implements Serializable {
private int idx;
private String url;
+ public Version() {
+ }
+
+ public Version(int idx) {
+ this.idx = idx;
+ }
+
@Id
@GeneratedValue
public Long getId() {
diff --git a/entity-view/api/pom.xml b/entity-view/api/pom.xml
index 4604fc98ee..32559e9d2d 100644
--- a/entity-view/api/pom.xml
+++ b/entity-view/api/pom.xml
@@ -47,4 +47,39 @@
provided
+
+
+
+
+ org.moditect
+ moditect-maven-plugin
+
+
+ add-module-infos
+ package
+
+ add-module-info
+
+
+ ${project.version}-module
+
+
+ module ${module.name} {
+ requires transitive com.blazebit.persistence.core;
+ exports com.blazebit.persistence.view;
+ exports com.blazebit.persistence.view.change;
+ exports com.blazebit.persistence.view.filter;
+ exports com.blazebit.persistence.view.metamodel;
+ exports com.blazebit.persistence.view.spi;
+ exports com.blazebit.persistence.view.spi.type;
+ uses com.blazebit.persistence.view.spi.EntityViewConfigurationProvider;
+ }
+
+
+
+
+
+
+
+
diff --git a/entity-view/impl/pom.xml b/entity-view/impl/pom.xml
index 5c0ffc582e..91d938d2a7 100644
--- a/entity-view/impl/pom.xml
+++ b/entity-view/impl/pom.xml
@@ -120,6 +120,174 @@
+
+ org.moditect
+ moditect-maven-plugin
+
+
+ add-module-infos
+ post-package
+
+ add-module-info
+
+
+ ${project.version}-module
+
+
+ module ${module.name} {
+ requires java.sql;
+ requires java.persistence;
+ requires com.blazebit.common.utils;
+ requires com.blazebit.persistence.core;
+ requires com.blazebit.persistence.core.parser;
+ requires com.blazebit.persistence.view;
+ exports com.blazebit.persistence.view.impl;
+ provides com.blazebit.persistence.view.spi.EntityViewConfigurationProvider with com.blazebit.persistence.view.impl.EntityViewConfigurationProviderImpl;
+ }
+
+
+
+
+
+
+
+
+
+ pre-10-unsafe-code
+
+ [1.7,11)
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+
+
+
+
+ post-10-unsafe-code
+
+ [11,)
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+
+ maven-compiler-plugin
+
+
+ default-compile
+ true
+
+
+
+ ${jdk8.classes.jar}
+
+ 1.8
+
+
+
+
+
+
+
+
+
+ post-8-unsafe-code
+
+ [1.9,)
+
+
+ src/main/java9
+
+
+
+
+ maven-antrun-plugin
+
+
+ compile-java9
+ compile
+
+
+
+
+
+
+
+ run
+
+
+
+
+
+ maven-jar-plugin
+ true
+
+
+
+ true
+
+
+
+
+
+ default-jar
+ package
+
+ jar
+
+
+
+ modular-jar
+ package
+
+ jar
+
+
+ module
+
+
+
+
+
+
+
+
diff --git a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/EntityViewManagerImpl.java b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/EntityViewManagerImpl.java
index 51e158298e..1d4e04ba15 100644
--- a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/EntityViewManagerImpl.java
+++ b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/EntityViewManagerImpl.java
@@ -28,6 +28,7 @@
import com.blazebit.persistence.parser.util.JpaMetamodelUtils;
import com.blazebit.persistence.spi.DbmsDialect;
import com.blazebit.persistence.spi.JpaProvider;
+import com.blazebit.persistence.spi.PackageOpener;
import com.blazebit.persistence.view.AttributeFilterProvider;
import com.blazebit.persistence.view.ConvertOption;
import com.blazebit.persistence.view.EntityViewManager;
@@ -107,6 +108,7 @@ public class EntityViewManagerImpl implements EntityViewManager {
private final JpaProvider jpaProvider;
private final DbmsDialect dbmsDialect;
private final ExpressionFactory expressionFactory;
+ private final PackageOpener packageOpener;
private final AttributeAccessor entityIdAccessor;
private final ViewMetamodelImpl metamodel;
private final ProxyFactory proxyFactory;
@@ -125,9 +127,10 @@ public EntityViewManagerImpl(EntityViewConfigurationImpl config, CriteriaBuilder
this.dbmsDialect = cbf.getService(DbmsDialect.class);
EntityMetamodel entityMetamodel = cbf.getService(EntityMetamodel.class);
this.expressionFactory = cbf.getService(ExpressionFactory.class);
+ this.packageOpener = cbf.getService(PackageOpener.class);
this.entityIdAccessor = new EntityIdAttributeAccessor(cbf.getService(EntityManagerFactory.class).getPersistenceUnitUtil());
this.unsafeDisabled = !Boolean.valueOf(String.valueOf(config.getProperty(ConfigurationProperties.PROXY_UNSAFE_ALLOWED)));
- this.proxyFactory = new ProxyFactory(unsafeDisabled);
+ this.proxyFactory = new ProxyFactory(unsafeDisabled, packageOpener);
boolean validateExpressions = !Boolean.valueOf(String.valueOf(config.getProperty(ConfigurationProperties.EXPRESSION_VALIDATION_DISABLED)));
diff --git a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java
index aa0fbd47cd..ba4cf0233f 100644
--- a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java
+++ b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java
@@ -18,6 +18,7 @@
import com.blazebit.lang.StringUtils;
import com.blazebit.persistence.parser.util.JpaMetamodelUtils;
+import com.blazebit.persistence.spi.PackageOpener;
import com.blazebit.persistence.view.CorrelationProvider;
import com.blazebit.persistence.view.EntityViewManager;
import com.blazebit.persistence.view.FlushMode;
@@ -111,6 +112,7 @@ public class ProxyFactory {
private final Object proxyLock = new Object();
private final ClassPool pool;
private final boolean unsafeDisabled;
+ private final PackageOpener packageOpener;
/**
* @author Christian Beikov
@@ -143,9 +145,10 @@ public int hashCode() {
}
}
- public ProxyFactory(boolean unsafeDisabled) {
+ public ProxyFactory(boolean unsafeDisabled, PackageOpener packageOpener) {
this.pool = new ClassPool(ClassPool.getDefault());
this.unsafeDisabled = unsafeDisabled;
+ this.packageOpener = packageOpener;
}
public Class extends T> getProxy(EntityViewManager entityViewManager, ManagedViewTypeImplementor viewType, ManagedViewTypeImplementor super T> inheritanceBase) {
@@ -204,7 +207,7 @@ public Class extends CorrelationProvider> getCorrelationProviderProxy(Class>
newConstructor.getMethodInfo().setCodeAttribute(bytecode.toCodeAttribute());
cc.addConstructor(newConstructor);
- return cc.toClass(correlated.getClassLoader(), null);
+ return (Class extends CorrelationProvider>) cc.toClass(correlated.getClassLoader(), null);
} catch (Exception ex) {
throw new RuntimeException("Probably we did something wrong, please contact us if you see this message.", ex);
} finally {
@@ -471,11 +474,14 @@ private Class extends T> createProxyClass(EntityViewManager entityViewMana
private Class extends T> defineOrGetClass(EntityViewManager entityViewManager, boolean unsafe, Class> clazz, String proxyClassName, CtClass cc) throws IOException, IllegalAccessException, NoSuchFieldException, CannotCompileException {
try {
+ // Ask the package opener to allow deep access, otherwise defining the class will fail
+ packageOpener.openPackageIfNeeded(clazz, clazz.getPackage().getName(), ProxyFactory.class);
+
Class extends T> c;
if (unsafe) {
c = (Class extends T>) UnsafeHelper.define(cc.getName(), cc.toBytecode(), clazz);
} else {
- c = cc.toClass(clazz.getClassLoader(), null);
+ c = (Class extends T>) cc.toClass(clazz.getClassLoader(), null);
}
c.getField("$$_evm").set(null, entityViewManager);
diff --git a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/CollectionAttributeFlusher.java b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/CollectionAttributeFlusher.java
index 8f756d56c6..d4645ed8dd 100644
--- a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/CollectionAttributeFlusher.java
+++ b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/CollectionAttributeFlusher.java
@@ -185,6 +185,43 @@ protected boolean executeActions(UpdateContext context, Collection