Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

[BUG] Code assist broken for userutil sources using Java 14+ syntax

未關閉
#327 1 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
java

研究方向

Start with com.mirth.connect.client.ui.reference.ReferenceListFactory#addUserutilReferences(String, InputStream) and identify the bundled JavaParser dependency and configured source level. Migrate its parsing and AST/visitor usage to the current com.github.javaparser API. Done means Java 17 syntax in a CLIENT userutil source is parsed and its class offers CTRL+space completions.

由索引模型根據 Issue 內容生成。

描述

bug

Describe the bug
The Java baseline for OIE is now Java 17, but the JavaParser library used to build code-assist references for the JavaScript editor is japa.parser JavaParser 1.0.8 (javaparser-1.0.8.jar), the legacy version that only understands an old Java grammar (no enhanced switch expressions, records, text blocks, etc.). When a CLIENT source library contains any class written with Java 14+ syntax, JavaParser fails to parse it at Administrator startup, the exception is caught and logged, and that class is dropped from the completion cache — so CTRL+space code assist is unavailable for it. Consistently reproducible.

To Reproduce
Setup: a custom extension/plugin that ships a *-userutil-sources.jar referenced in its metadata as a CLIENT library.

  1. In a userutil class, use any Java 14+ syntax (e.g. a switch expression):
   /**
    * Returns a human-readable label for the given priority code.
    *
    * @param code the single-character priority code
    * @return the corresponding label
    */
   public static String priorityLabel(final char code) {
       // Java 14+ switch expression — not parseable by JavaParser 1.0.8.
       return switch (code) {
           case 'H' -> "High";
           case 'M' -> "Medium";
           case 'L' -> "Low";
           default  -> "Unknown";
       };
   }
  1. Package the sources into myext-userutil-sources.jar.
  2. Register it as a CLIENT source library in the extension metadata:
   <library type="CLIENT" path="src/myext-userutil-sources.jar" />
  1. Start the Administrator (this is when userutil sources are parsed and the reference/completion cache is built).
  2. Open a transformer in the JavaScript editor and trigger code assist (CTRL+space) against the class.

Expected behavior
Since the project baseline is Java 17, the JavaParser used to build code-assist references should be able to parse Java 17 source, so the userutil class loads normally and CTRL+space offers completions for it.

Actual behavior
At Administrator startup, JavaParser.parse(is) in com.mirth.connect.client.ui.reference.ReferenceListFactory#addUserutilReferences(String, InputStream) throws a parse exception on the Java 14+ syntax. The catch (Exception e) swallows it and logs:

ERROR ... ReferenceListFactory - Unable to load references from userutil entry <package>/<Class>.java
japa.parser.ParseException: ...

The class is skipped, so no references are built and CTRL+space offers no completions for it — even though the same code compiles and runs fine under the Java 17 baseline.

Screenshots
N/A

Environment (please complete the following information):

  • OS: Windows 11
  • Java Distribution/Version: OpenJDK 17
  • Connect Version: 4.5.2

Workaround(s)
Avoid Java 14+ syntax in any source that ends up in a CLIENT sources jar. For switch expressions, fall back to a classic switch statement:

public static String priorityLabel(final char code) {
    switch (code) {
        case 'H': return "High";
        case 'M': return "Medium";
        case 'L': return "Low";
        default:  return "Unknown";
    }
}

The class still compiles and runs under Java 17; only the syntax exposed to JavaParser is downgraded. Note this is per-class: one offending class only drops its own references, not the whole jar.

Additional context
Root cause is a mismatch between the Java baseline (17) and the bundled JavaParser (japa.parser 1.0.8), which predates modern Java grammar by many language versions. The legacy japa.parser line is no longer maintained; the project moved to com.github.javaparser (3.x), which tracks current Java language levels. A fix would be to migrate ReferenceListFactory from japa.parser.* to a current com.github.javaparser:javaparser-core and keep it aligned with the configured source level. The API differs between the two (e.g. JavaParser.parse(InputStream) and the AST/visitor packages changed), so this is a small migration rather than a drop-in version bump.

I would be happy to work on this one if it has potential to me merged...

主要語言
Java
星號
227
分支
81
平均合併
3 天 6 小時
30 天內合併 PR
15

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

OpenIntegrationEngine/engine 的其他 Issue

查看 OpenIntegrationEngine/engine 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。