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.ArchiveException;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.ClassSummary;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.Indexer;
@ -61,17 +61,16 @@ public class ClassFileArchiveEntryHandler implements ArchiveEntryHandler {
private ClassDescriptor toClassDescriptor(ArchiveEntry entry) {
try (InputStream inputStream = entry.getStreamAccess().accessInputStream()) {
Indexer indexer = new Indexer();
indexer.index( inputStream );
ClassSummary classSummary = indexer.indexWithSummary( inputStream );
Index index = indexer.complete();
ClassInfo classInfo = index.getKnownClasses().iterator().next();
return toClassDescriptor( classInfo, index, entry );
return toClassDescriptor( classSummary, index, entry );
}
catch (IOException 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;
if ( isModel( index ) ) {
@ -81,7 +80,7 @@ public class ClassFileArchiveEntryHandler implements ArchiveEntryHandler {
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) {

View File

@ -16,7 +16,7 @@ buildDir = "target"
dependencies {
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 'jakarta.json.bind:jakarta.json.bind-api:2.0.0'
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.jboss.jandex.ClassInfo;
import org.jboss.jandex.ClassSummary;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexReader;
import org.jboss.jandex.IndexWriter;
@ -168,8 +169,17 @@ public class IndexManager {
}
if ( relativePath.getPathString().endsWith( ".class" ) ) {
try ( final FileInputStream stream = new FileInputStream( details.getFile() ) ) {
indexer.index( stream );
try (final FileInputStream stream = new FileInputStream( details.getFile() )) {
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) {
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();
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() ) {
return null;
}

View File

@ -79,7 +79,7 @@ dependencyResolutionManagement {
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( "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( "jackson" ).to ( "com.fasterxml.jackson.core", "jackson-databind" ).version( "2.13.0" )