HHH-15465 Upgrade to Jandex 3.0.0

This commit is contained in:
Andrea Boriero 2022-08-26 15:04:36 +02:00 committed by Christian Beikov
parent 17fa97d1b0
commit 6cf9d2d480
5 changed files with 20 additions and 11 deletions

View File

@ -20,7 +20,7 @@ import org.hibernate.boot.archive.spi.ArchiveEntry;
import org.hibernate.boot.archive.spi.ArchiveEntryHandler; import org.hibernate.boot.archive.spi.ArchiveEntryHandler;
import org.hibernate.boot.archive.spi.ArchiveException; import org.hibernate.boot.archive.spi.ArchiveException;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassSummary;
import org.jboss.jandex.DotName; import org.jboss.jandex.DotName;
import org.jboss.jandex.Index; import org.jboss.jandex.Index;
import org.jboss.jandex.Indexer; import org.jboss.jandex.Indexer;
@ -61,17 +61,16 @@ public class ClassFileArchiveEntryHandler implements ArchiveEntryHandler {
private ClassDescriptor toClassDescriptor(ArchiveEntry entry) { private ClassDescriptor toClassDescriptor(ArchiveEntry entry) {
try (InputStream inputStream = entry.getStreamAccess().accessInputStream()) { try (InputStream inputStream = entry.getStreamAccess().accessInputStream()) {
Indexer indexer = new Indexer(); Indexer indexer = new Indexer();
indexer.index( inputStream ); ClassSummary classSummary = indexer.indexWithSummary( inputStream );
Index index = indexer.complete(); Index index = indexer.complete();
ClassInfo classInfo = index.getKnownClasses().iterator().next(); return toClassDescriptor( classSummary, index, entry );
return toClassDescriptor( classInfo, index, entry );
} }
catch (IOException e) { catch (IOException e) {
throw new ArchiveException( "Could not build ClassInfo", e ); throw new ArchiveException( "Could not build ClassInfo", e );
} }
} }
private ClassDescriptor toClassDescriptor(ClassInfo classInfo, Index index, ArchiveEntry entry) { private ClassDescriptor toClassDescriptor(ClassSummary classSummary, Index index, ArchiveEntry entry) {
ClassDescriptor.Categorization categorization = ClassDescriptor.Categorization.OTHER; ClassDescriptor.Categorization categorization = ClassDescriptor.Categorization.OTHER;
if ( isModel( index ) ) { if ( isModel( index ) ) {
@ -81,7 +80,7 @@ public class ClassFileArchiveEntryHandler implements ArchiveEntryHandler {
categorization = ClassDescriptor.Categorization.CONVERTER; categorization = ClassDescriptor.Categorization.CONVERTER;
} }
return new ClassDescriptorImpl( classInfo.name().toString(), categorization, entry.getStreamAccess() ); return new ClassDescriptorImpl( classSummary.name().toString(), categorization, entry.getStreamAccess() );
} }
private boolean isConverter(Index index) { private boolean isConverter(Index index) {

View File

@ -16,7 +16,7 @@ buildDir = "target"
dependencies { dependencies {
implementation gradleApi() implementation gradleApi()
implementation 'org.jboss:jandex:2.4.2.Final' implementation 'io.smallrye:jandex:3.0.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.13' implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'jakarta.json.bind:jakarta.json.bind-api:2.0.0' implementation 'jakarta.json.bind:jakarta.json.bind-api:2.0.0'
implementation 'jakarta.json:jakarta.json-api:2.0.1' implementation 'jakarta.json:jakarta.json-api:2.0.1'

View File

@ -28,6 +28,7 @@ import org.gradle.api.file.RelativePath;
import org.gradle.api.provider.Provider; import org.gradle.api.provider.Provider;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.ClassSummary;
import org.jboss.jandex.Index; import org.jboss.jandex.Index;
import org.jboss.jandex.IndexReader; import org.jboss.jandex.IndexReader;
import org.jboss.jandex.IndexWriter; import org.jboss.jandex.IndexWriter;
@ -169,7 +170,16 @@ public class IndexManager {
if ( relativePath.getPathString().endsWith( ".class" ) ) { if ( relativePath.getPathString().endsWith( ".class" ) ) {
try (final FileInputStream stream = new FileInputStream( details.getFile() )) { try (final FileInputStream stream = new FileInputStream( details.getFile() )) {
indexer.index( stream ); final ClassSummary classSummary = indexer.indexWithSummary( stream );
if ( classSummary == null ) {
project.getLogger()
.lifecycle( "Problem indexing class file - " + details.getFile()
.getAbsolutePath() );
}
}
catch (IllegalArgumentException e) {
throw new RuntimeException( "Problem indexing class file - " + details.getFile()
.getAbsolutePath(), e );
} }
catch (FileNotFoundException e) { catch (FileNotFoundException e) {
throw new RuntimeException( "Problem locating project class file - " + details.getFile() throw new RuntimeException( "Problem locating project class file - " + details.getFile()

View File

@ -115,7 +115,7 @@ public abstract class LoggingReportTask2 extends AbstractJandexAwareTask {
final ClassInfo loggerClassInfo = msgLoggerAnnUsage.target().asClass(); final ClassInfo loggerClassInfo = msgLoggerAnnUsage.target().asClass();
getProject().getLogger().lifecycle( "MessageLogger (`%s`) missing id-range", loggerClassInfo.simpleName() ); getProject().getLogger().lifecycle( "MessageLogger (`%s`) missing id-range", loggerClassInfo.simpleName() );
final List<AnnotationInstance> messageAnnUsages = loggerClassInfo.annotations().get( MSG_ANN_NAME ); final List<AnnotationInstance> messageAnnUsages = loggerClassInfo.annotations( MSG_ANN_NAME );
if ( messageAnnUsages.isEmpty() ) { if ( messageAnnUsages.isEmpty() ) {
return null; return null;
} }

View File

@ -79,7 +79,7 @@ dependencyResolutionManagement {
alias( "loggingProcessor" ).to ( "org.jboss.logging", "jboss-logging-processor" ).version( "2.2.1.Final" ) alias( "loggingProcessor" ).to ( "org.jboss.logging", "jboss-logging-processor" ).version( "2.2.1.Final" )
alias( "hcann" ).to( "org.hibernate.common", "hibernate-commons-annotations" ).versionRef( "hcann" ) alias( "hcann" ).to( "org.hibernate.common", "hibernate-commons-annotations" ).versionRef( "hcann" )
alias( "jandex" ).to("org.jboss", "jandex" ).version( "2.4.2.Final" ) alias( "jandex" ).to("io.smallrye", "jandex" ).version( "3.0.0" )
alias( "classmate" ).to( "com.fasterxml", "classmate" ).version( "1.5.1" ) alias( "classmate" ).to( "com.fasterxml", "classmate" ).version( "1.5.1" )
alias( "jackson" ).to ( "com.fasterxml.jackson.core", "jackson-databind" ).version( "2.13.0" ) alias( "jackson" ).to ( "com.fasterxml.jackson.core", "jackson-databind" ).version( "2.13.0" )