JDK types first reached by a source scan stay uninspected when any package is preloaded: `isFunctionalInterface()` is false for `PrivilegedAction`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start by tracing ClassSymbolScanner.loadType(..., LAZILY) and the JavaInspectorImpl copy and commit loops described in the issue, then compare the preload and no-preload paths in the reproduction. Check how CompiledTypesManagerImpl.preload and on-demand inspection affect the type's inspection state. Done means the reproduced PrivilegedAction reports run() as its single abstract method and isFunctionalInterface() returns true after parsing with any preload.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Reproduction
SourceSet javaBase = SourceSetImpl.javaBase();
SourceSet sources = new SourceSetImpl.Builder().setName(JavaInspector.TEST_PROTOCOL)
.setUri(URI.create("file:/")).setDependencies(List.of(javaBase)).build();
InputConfiguration config = new InputConfigurationImpl.Builder().addSourceSets(sources)
.addClassPath("jmod:java.base").build();
JavaInspector ji = new io.codelaser.maddi.inspection.openjdk.JavaInspectorImpl();
ji.preload("java.base::java.util."); // any preload; see the table below
ji.initialize(config);
TypeInfo x = ji.parse(Map.of("a.X", """
package a;
import java.security.PrivilegedAction;
class X {
static String m() {
PrivilegedAction<String> action = () -> "x";
return action.run();
}
}
"""), new JavaInspector.ParseOptions.Builder().build())
.parseResult().primaryTypes().stream().findFirst().orElseThrow();
// visit m()'s body, take the Lambda, and inspect l.abstractFunctionalTypeInfo()
| preloads | PrivilegedAction after parse |
|---|---|
| none | hasBeenInspected()=true, singleAbstractMethod()=run(), isFunctionalInterface()=true |
java.base::java.util. |
hasBeenInspected()=false, singleAbstractMethod()=null, isFunctionalInterface()=false |
java.base::java.util. + java.base::java.security |
hasBeenInspected()=true, run(), true |
Seen on 0.9.5-alpha.11.
Expected
After parse returns, every type the parse result refers to answers member queries correctly, whatever was preloaded. Failing that, it should answer by completing the type on demand. A TypeInfo that silently reports "no single abstract method" while the parser has just resolved a lambda against it is the worst case: callers can't tell an uninspected type from a non-functional one.
Where it seems to come from
This is from reading the code; I haven't stepped through it.
ClassSymbolScanner.loadType(..., LAZILY)skips the members andsetSingleAbstractMethod, and doesn't commit.- The type is completed later, by
JavaInspectorImpl's "copy into CTM" loop. That loop commitsscanned.primaryTypes(),classSymbolScanner().typesLoaded()(=infoByFqn.typesLoadedForThisSourceSet()), and the preloads. - With a preload, a shared-JDK task exists (
preloadPass/wireSharedJdk). A platform type first reached during the source scan is then loaded on that shared task and registered for the JDK source set. It is not registered for the scanned set, so the loop never sees it. The preload pass's own commit loop has already run by then. - Without any preload there is no shared task, so the scanner's own
typesLoaded()includes the type and it gets committed. - Also,
CompiledTypesManagerImpl.preloadis a TODO, and LAZILY-loaded types from the openjdk scanner don't registersetOnDemandInspection. SoTypeInfoImpl.inspection.get()returns the uncommitted builder instead of completing the type.
Impact
Code that branches on isFunctionalInterface() or singleAbstractMethod() for a lambda's or method reference's target type gets the wrong answer whenever that JDK interface wasn't covered by a preload. The same probably holds for any other member query on such a type (methods(), fields(), ...).
- Lingua principale
- Java
- Stelle
- 1
- Fork
- 1
- Merge medio
- 1h 55m
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CodeLaser/maddi
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CodeLaser/maddi#166 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
build/ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
-
Java printer: a class literal in an annotation value prints by simple name, without an importApertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di CodeLaser/maddi
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
geonetwork/core-geonetwork#9592 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/rocketmq-dashboard#7361 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
higress-group/himarket#358 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno