JDK types first reached by a source scan stay uninspected when any package is preloaded: `isFunctionalInterface()` is false for `PrivilegedAction`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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(), ...).
- 主要言語
- Java
- スター
- 1
- フォーク
- 1
- 平均マージ
- 1時間 44分
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CodeLaser/maddi のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
CodeLaser/maddi#166 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
build/ci good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 14/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
CodeLaser/maddi の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 3 日以内に返信
-
A proxy that fails to start logs a RejectedExecutionException stack trace from its shutdown hookオープンfollow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Sanne/incus-spawn#1953 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
atlassian/data-center-helm-charts#1170 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
Issue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
OpenAPITools/openapi-generator#25524 ·
メンテナーはふだん 1 日以内に返信