HHH-17210 Add annotation to suppress ForbiddenAPI non portable failures for jdk.jfr

This commit is contained in:
Andrea Boriero 2023-09-28 11:51:19 +02:00 committed by Steve Ebersole
parent 9ce2d25041
commit e4128b1e1a
5 changed files with 25 additions and 1 deletions

View File

@ -14,7 +14,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'de.thetaphi:forbiddenapis:3.2'
classpath 'de.thetaphi:forbiddenapis:3.5.1'
}
}
@ -516,6 +516,7 @@ task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) {
task forbiddenApisNonPortable(type: CheckForbiddenApis, dependsOn: compileJava) {
bundledSignatures += 'jdk-non-portable'
suppressAnnotations += ['org.hibernate.internal.build.AllowNonPortable']
}
task forbiddenApis {

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.event.jfr;
import org.hibernate.internal.build.AllowNonPortable;
import jdk.jfr.Category;
import jdk.jfr.Description;
import jdk.jfr.Event;
@ -21,6 +23,7 @@ import jdk.jfr.StackTrace;
@Category("Hibernate ORM")
@Description("Hibernate Session closed")
@StackTrace(false)
@AllowNonPortable
public class SessionClosedEvent extends Event {
public static final String NAME = "org.hibernate.orm.SessionClosed";

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.event.jfr;
import org.hibernate.internal.build.AllowNonPortable;
import jdk.jfr.Category;
import jdk.jfr.Description;
import jdk.jfr.Event;
@ -21,6 +23,7 @@ import jdk.jfr.StackTrace;
@Category("Hibernate ORM")
@Description("Hibernate Session opened")
@StackTrace(false)
@AllowNonPortable
public class SessionOpenEvent extends Event {
public static final String NAME = "org.hibernate.orm.SessionOpened";

View File

@ -110,6 +110,7 @@ import org.hibernate.event.spi.SaveOrUpdateEventListener;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.internal.RootGraphImpl;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.internal.build.AllowNonPortable;
import org.hibernate.internal.util.ExceptionHelper;
import org.hibernate.jpa.internal.LegacySpecHelper;
import org.hibernate.jpa.internal.util.ConfigurationHelper;
@ -227,6 +228,7 @@ public class SessionImpl
// TODO: this is unused and can be removed
private transient boolean isEnforcingFetchGraph;
@AllowNonPortable
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
super( factory, options );
@ -423,6 +425,7 @@ public class SessionImpl
closeWithoutOpenChecks();
}
@AllowNonPortable
public void closeWithoutOpenChecks() throws HibernateException {
if ( log.isTraceEnabled() ) {
log.tracef( "Closing session [%s]", getSessionIdentifier() );

View File

@ -0,0 +1,14 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.internal.build;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention( RetentionPolicy.CLASS )
public @interface AllowNonPortable {
}