-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for java.lang.StackOverflowError after bumping from 4.0.0 to 4.0.…
…1 after ASM refactor (#1841) Fixes #1832 This PR contains fix for reported error and new JPA test module as this issue happens when AspectJ Weaver is applied to JPA managed classes. It was related with EntityManagerFactory.getMetamodel(); Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
- Loading branch information
Showing
10 changed files
with
466 additions
and
0 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
jpa/eclipselink.jpa.testapps/jpa.test.metamodel.apectj/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0 which is available at | ||
http://www.eclipse.org/legal/epl-2.0, | ||
or the Eclipse Distribution License v. 1.0 which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>org.eclipse.persistence.jpa.testapps</artifactId> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<version>4.0.2-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>org.eclipse.persistence.jpa.testapps.metamodel.aspectj</artifactId> | ||
|
||
<name>Test - metamodel.aspectj</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjrt</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjweaver</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-compile</id> | ||
<phase>none</phase> | ||
</execution> | ||
<execution> | ||
<id>compile-with-processor</id> | ||
<phase>compile</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>aspectj-maven-plugin</artifactId> | ||
<configuration> | ||
<complianceLevel>${maven.compiler.release}</complianceLevel> | ||
<source>${maven.compiler.release}</source> | ||
<target>${maven.compiler.release}</target> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.carlspring.maven</groupId> | ||
<artifactId>derby-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>start-derby</id> | ||
<phase>process-test-classes</phase> | ||
</execution> | ||
<execution> | ||
<id>stop-derby</id> | ||
<phase>prepare-package</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>server-test</id> | ||
<configuration> | ||
<excludes> | ||
<exclude>**/EntityManagerImplTest</exclude> | ||
<exclude>**/EntityManagerFactoryImplTest</exclude> | ||
</excludes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>package-model</id> | ||
<phase>package</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
...java/org/eclipse/persistence/testing/models/jpa/weaving/aspectj/EntityListenerAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial implementation | ||
package org.eclipse.persistence.testing.models.jpa.weaving.aspectj; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
|
||
@Aspect | ||
public class EntityListenerAspect { | ||
|
||
@Before(value = "execution (* org.eclipse.persistence.testing.models.jpa.weaving.aspectj.EntityListenerAspectJ.*(..))") | ||
public void before(JoinPoint joinPoint) { | ||
System.out.println("AspectJ method call from EntityListener"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ava/org/eclipse/persistence/testing/models/jpa/weaving/aspectj/EntityListenerAspectJ.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial implementation | ||
package org.eclipse.persistence.testing.models.jpa.weaving.aspectj; | ||
|
||
import jakarta.persistence.PrePersist; | ||
|
||
public class EntityListenerAspectJ { | ||
|
||
@PrePersist | ||
public void logBeforeCreate(Object target) { | ||
System.out.println("Before create:\t" + target); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...src/main/java/org/eclipse/persistence/testing/models/jpa/weaving/aspectj/ItemAspectJ.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial implementation | ||
package org.eclipse.persistence.testing.models.jpa.weaving.aspectj; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
|
||
@Entity | ||
@Table(name="ASPECTJ_ITEM") | ||
@EntityListeners({EntityListenerAspectJ.class}) | ||
public class ItemAspectJ { | ||
@Id | ||
private long id; | ||
private String name; | ||
|
||
public ItemAspectJ() { | ||
} | ||
|
||
public ItemAspectJ(long id, String aaaa) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ItemAspectJ{" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...selink.jpa.testapps/jpa.test.metamodel.apectj/src/main/resources/META-INF/persistence.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0 which is available at | ||
http://www.eclipse.org/legal/epl-2.0, | ||
or the Eclipse Distribution License v. 1.0 which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
--> | ||
|
||
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"> | ||
<persistence-unit name="ignore" transaction-type="JTA"> | ||
<description>This PU is for validation purpose only - it should not | ||
break the rest of the tests</description> | ||
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> | ||
<jta-data-source>java:comp/DefaultDataSource</jta-data-source> | ||
</persistence-unit> | ||
|
||
<persistence-unit name="metamodel1_aspectj"> | ||
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> | ||
<class>org.eclipse.persistence.testing.models.jpa.weaving.aspectj.ItemAspectJ</class> | ||
<class>org.eclipse.persistence.testing.models.jpa.weaving.aspectj.EntityListenerAspectJ</class> | ||
<exclude-unlisted-classes>true</exclude-unlisted-classes> | ||
<properties> | ||
<property name="eclipselink.session-name" value="isolated-session1053"/> | ||
<property name="eclipselink.cache.shared.default" value="false"/> | ||
<property name="eclipselink.logging.level" value="${eclipselink.logging.level}"/> | ||
<property name="eclipselink.logging.level.sql" value="${eclipselink.logging.sql.level}"/> | ||
<property name="eclipselink.logging.parameters" value="${eclipselink.logging.parameters}"/> | ||
</properties> | ||
</persistence-unit> | ||
</persistence> |
58 changes: 58 additions & 0 deletions
58
...g/eclipse/persistence/testing/tests/jpa/weaving/aspectj/MetamodelAspectJTableCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.tests.jpa.weaving.aspectj; | ||
|
||
import org.eclipse.persistence.tools.schemaframework.FieldDefinition; | ||
import org.eclipse.persistence.tools.schemaframework.TableCreator; | ||
import org.eclipse.persistence.tools.schemaframework.TableDefinition; | ||
|
||
public class MetamodelAspectJTableCreator extends TableCreator { | ||
|
||
public MetamodelAspectJTableCreator() { | ||
setName("JPAOrphanRemovalModelTableCreator"); | ||
addTableDefinition(buildVEHICLETable()); | ||
} | ||
|
||
public static TableDefinition buildVEHICLETable() { | ||
// CREATE TABLE ASPECTJ_ITEM (ID NUMBER(10) NOT NULL, NAME VARCHAR2(255) NULL, PRIMARY KEY (ID)) | ||
TableDefinition table = new TableDefinition(); | ||
table.setName("ASPECTJ_ITEM"); | ||
|
||
FieldDefinition fieldID = new FieldDefinition(); | ||
fieldID.setName("ID"); | ||
fieldID.setTypeName("NUMERIC"); | ||
fieldID.setSize(10); | ||
fieldID.setSubSize(0); | ||
fieldID.setIsPrimaryKey(true); | ||
fieldID.setIsIdentity(true); | ||
fieldID.setShouldAllowNull(false); | ||
fieldID.setUnique(false); | ||
table.addField(fieldID); | ||
|
||
FieldDefinition fieldMODEL = new FieldDefinition(); | ||
fieldMODEL.setName("NAME"); | ||
fieldMODEL.setTypeName("VARCHAR"); | ||
fieldMODEL.setSize(60); | ||
fieldMODEL.setSubSize(0); | ||
fieldMODEL.setIsPrimaryKey(false); | ||
fieldMODEL.setIsIdentity(false); | ||
fieldMODEL.setShouldAllowNull(true); | ||
fieldMODEL.setUnique(false); | ||
table.addField(fieldMODEL); | ||
|
||
return table; | ||
} | ||
|
||
} |
Oops, something went wrong.