processing / processing/processing4

Building processing throws `UnsupportedClassVersionError` in `:core:examples:Basic.main()`

未关闭
#1,428 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
494
派生
183
平均合并
4 小时 39 分钟
30 天内合并 PR
3

描述

I try to build processing with a clean clone of the repository.

Following the build instructions:
https://github.com/processing/processing4/blob/main/BUILD.md

1

The run button doesn't work in IntelliJ:

13:23:05: Executing ':core:examples:Basic.main()'…

Task :plugins:library:checkKotlinGradlePluginConfigurationErrors SKIPPED
Task :plugins:library:compileKotlin UP-TO-DATE
Task :plugins:library:compileJava NO-SOURCE
Task :plugins:library:pluginDescriptors UP-TO-DATE
Task :plugins:library:processResources UP-TO-DATE
Task :plugins:library:classes UP-TO-DATE
Task :plugins:library:jar UP-TO-DATE
Task :core:checkKotlinGradlePluginConfigurationErrors SKIPPED
Task :core:compileKotlin NO-SOURCE

Task :core:compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Task :core:processResources
Task :core:classes
Task :core:jar

Task :core:examples:compileJava

Task :core:examples:processResources NO-SOURCE
Task :core:examples:classes
Note: /Users/doeke/Documents/processing4-w_branches/core/examples/src/main/java/Basic.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Task :core:examples:Basic.main() FAILED
[Incubating] Problems report is available at: file:///Users/doeke/Documents/processing4-w_branches/.build/reports/problems/problems-report.html
9 actionable tasks: 5 executed, 4 up-to-date
Error: LinkageError occurred while loading main class Basic
java.lang.UnsupportedClassVersionError: Basic has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':core:examples:Basic.main()'.

Process 'command '/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 2s
13:23:08: Execution finished ':core:examples:Basic.main()'.

Which is triggered by: Runtime.getRuntime().exec("echo Hello World");

If I comment out those lines then I get:

17:06:15: Executing ':core:examples:Basic.main()'…

Task :plugins:library:checkKotlinGradlePluginConfigurationErrors SKIPPED
Task :plugins:library:compileKotlin UP-TO-DATE
Task :plugins:library:compileJava NO-SOURCE
Task :plugins:library:pluginDescriptors UP-TO-DATE
Task :plugins:library:processResources UP-TO-DATE
Task :plugins:library:classes UP-TO-DATE
Task :plugins:library:jar UP-TO-DATE
Task :core:checkKotlinGradlePluginConfigurationErrors SKIPPED
Task :core:compileKotlin NO-SOURCE
Task :core:compileJava UP-TO-DATE
Task :core:processResources UP-TO-DATE
Task :core:classes UP-TO-DATE
Task :core:jar UP-TO-DATE
Task :core:examples:compileJava
Task :core:examples:processResources NO-SOURCE
Task :core:examples:classes

Task :core:examples:Basic.main() FAILED
9 actionable tasks: 2 executed, 7 up-to-date
Error: LinkageError occurred while loading main class Basic
java.lang.UnsupportedClassVersionError: Basic has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':core:examples:Basic.main()'.

Process 'command '/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 872ms
17:06:16: Execution finished ':core:examples:Basic.main()'.

And so on...
Also if I check the module settings in IntelliJ then they default to 21 for me.
Upon checking the gradle files I see nowhere something among the lines of:

languageVersion = JavaLanguageVersion.of(17)

It seems like whoever made processing move away from maven to gradle had only JDK 17 installed.
I don't want to dig deeper cause I simply don't have the time but it would be nice if some housekeeping would take place.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先从 BUILD.md 和 Gradle 文件开始,然后使用报告中的 JDK 17 runtime 重现 :core:examples:Basic.main()。追踪 Basic 被编译为类文件版本 65、却在仅支持版本 61 的 runtime 上运行的原因;完成标准是文档中的构建和示例运行均可在没有 UnsupportedClassVersionError 的情况下正常工作。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
build-system
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。