Skip to content

Fix reflection excpetion, add missing opens#15307

Merged
koppor merged 1 commit into
mainfrom
fixTooltipReflection
Mar 9, 2026
Merged

Fix reflection excpetion, add missing opens#15307
koppor merged 1 commit into
mainfrom
fixTooltipReflection

Conversation

@Siedlerchr

Copy link
Copy Markdown
Member

Follow up to #15260

Encountered by @ThiloteE while indexing pdfs

Related issues and pull requests

Closes _____

PR Description

Steps to test

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • [.] I manually tested my changes in running JabRef (always required)
  • [.] I added JUnit tests for changes (if applicable)
  • [.] I added screenshots in the PR description (if change is visible to the user)
  • [.] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [.] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [.] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@Siedlerchr Siedlerchr changed the title Fix reflection excpetion, add missing Fix reflection excpetion, add missing opens Mar 9, 2026
@Siedlerchr Siedlerchr added the automerge PR is tagged with that label will be merged if workflows are green label Mar 9, 2026
@koppor koppor enabled auto-merge March 9, 2026 20:16
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add missing javafx.controls module opening for reflection

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Add missing module opening for reflection access
• Fixes reflection exception in ActionFactory#enableTooltips
• Enables PDF indexing functionality to work properly
Diagram
flowchart LR
  A["javafx-controls module"] -- "requires reflection access" --> B["com.sun.javafx.scene.control"]
  B -- "opens statement added" --> C["ActionFactory#enableTooltips"]
  C -- "enables" --> D["PDF indexing"]
Loading

Grey Divider

File Changes

1. build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts 🐞 Bug fix +2/-0

Add missing javafx.controls module opening

• Added opens("com.sun.javafx.scene.control") statement to javafx-controls module configuration
• Includes explanatory comment referencing ActionFactory#enableTooltips requirement
• Resolves reflection exception encountered during PDF indexing operations

build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Overbroad module opens 🐞 Bug ⛨ Security
Description
The new opens("com.sun.javafx.scene.control") is unqualified, so it grants deep-reflection access
to this internal JavaFX package to any module on the module path, not just JabRef. This weakens
encapsulation and expands reflective access beyond what ActionFactory requires for tooltips.
Code

build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts[R492-493]

+        // required for ActionFactory#enableTooltips
+        opens("com.sun.javafx.scene.control")
Evidence
ActionFactory uses getDeclaredMethod + setAccessible(true) against
com.sun.javafx.scene.control.ContextMenuContent.MenuItemContainer, which requires the
javafx.controls module to open that package at runtime; however, the added opens(...) is
unqualified and therefore opens it to all modules. The build logic DSL in this repo already supports
qualified opens (package opened to a specific module), and JabRef’s consuming module name is
org.jabref, so the access can be narrowed.

build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts[486-494]
jabgui/src/main/java/org/jabref/gui/actions/ActionFactory.java[56-69]
jabgui/src/main/java/module-info.java[1-18]
build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts[455-461]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`javafx.controls` currently uses an **unqualified** `opens("com.sun.javafx.scene.control")`, which opens an internal JavaFX package to *all* modules. JabRef’s tooltip code needs deep reflection here, but that access can likely be limited to JabRef’s own module (`org.jabref`) to reduce reflective surface area.

### Issue Context
`org.jabref.gui.actions.ActionFactory#getAssociatedNode` reflects into `com.sun.javafx.scene.control.ContextMenuContent.MenuItemContainer` via `setAccessible(true)`, which requires `javafx.controls` to open `com.sun.javafx.scene.control`.

### Fix Focus Areas
- build-logic/src/main/kotlin/org.jabref.gradle.base.dependency-rules.gradle.kts[486-494]

### Suggested change
Replace:
- `opens("com.sun.javafx.scene.control")`

With (minimum):
- `opens("com.sun.javafx.scene.control", "org.jabref")`

If tests or other runtime modules also reflect into this package, add them explicitly as additional qualified targets rather than keeping it unqualified.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@koppor koppor added this pull request to the merge queue Mar 9, 2026
@testlens-app

testlens-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: bb4d7b1
▶️ Tests: 10126 executed
⚪️ Checks: 86/86 completed


Learn more about TestLens at testlens.app.

@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Mar 9, 2026
Merged via the queue into main with commit b948fe0 Mar 9, 2026
78 of 87 checks passed
@koppor koppor deleted the fixTooltipReflection branch March 9, 2026 20:56
Siedlerchr added a commit to statxc/jabref that referenced this pull request Mar 10, 2026
* upstream/main:
  fix jbang (JabRef#15311)
  New Crowdin updates (JabRef#15310)
  Fix exception in ExtractReferences from pdf (JabRef#15308)
  feat: add --entry-type-pattern option to citationkeys generate command (JabRef#15072)
  Fix reflection excpetion, add missing (JabRef#15307)
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 14, 2026
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge PR is tagged with that label will be merged if workflows are green status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants