Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Optimize ClassGraph Scanning

Aperta
#627 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
api, backend

Direzione di ricerca

Start with SerializerRegistryImpl.findAndSetContents() and RoutingRegistryImpl.findAndSetContracts(), then review their ClassGraph scan setup and the ScanResult.toJSON()/fromJSON() APIs. Determine how optional packaged metadata can be shared by both registries while preserving runtime scanning when absent. Done means startup discovers serializers, contracts, and data types without duplicate full-classpath scans when an index is present, with fallback and GraalVM Native Image limitations documented.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
Current Status

The Java contract API performs two separate ClassGraph scans during startup:

  1. SerializerRegistryImpl.findAndSetContents() scans the runtime classpath for classes annotated with @Serializer.
  2. RoutingRegistryImpl.findAndSetContracts() scans the runtime classpath for classes annotated with @Contract and @DataType.

Both scans use new ClassGraph().enableClassInfo().enableAnnotationInfo().scan(). For chaincodes with many dependencies, scanning the full classpath can increase startup time. This work is repeated whenever the chaincode starts, including when a peer restarts and launches its chaincode again.

ClassGraph provides ScanResult.toJSON() and ScanResult.fromJSON(String) APIs that may allow scan metadata to be generated during the build and reused at runtime.

Expected

Chaincode startup should be able to discover serializers, contracts, and data types from pre-generated scan metadata rather than scanning the full runtime classpath each time.

The change should preserve existing behavior for users who do not provide generated metadata. It should also document any limitations or additional requirements for using this approach with GraalVM Native Image, where dynamic class loading and reflection may require build-time configuration.

Solution

Add an optional build-time scan-index mechanism that packages ClassGraph metadata with the chaincode. At runtime, the shim should load that metadata and share the resulting scan information between SerializerRegistryImpl and RoutingRegistryImpl, avoiding duplicate full-classpath scans.

When no index is available, the shim should fall back to the current runtime scanning behavior. The implementation could use ClassGraph's ScanResult.toJSON() and ScanResult.fromJSON(String) APIs, or another generated-index approach, while ensuring discovered classes can still be loaded and instantiated. Any extra GraalVM Native Image configuration needed for those classes should be documented.

Please let us know if you plan to work on this.

Yes!

Lingua principale
Java
Stelle
322
Fork
210
Merge medio
15h 16m
PR unite (30g)
29

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hyperledger/fabric-chaincode-java

Tutte le issue di hyperledger/fabric-chaincode-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.