You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java编译报错:Uncompilable source code错误原因咨询

Java编译错误原因解析:Erroneous tree type:

问题代码

package fungsi;

public class Main {
    public static void main (String[] args) {
        
        //void artinya hampa
        System.out.println(simpel());
        
        fungsiVoid( input: "apa pun");
    }

    private static void fungsiVoid (String input) {
        System.out.println(input);
    }

    private static float simpel() {
        return 10.0f;
    }
    
    private static int farhan() {
        return 0;
    }
}

触发的错误信息

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
    at fungsi.Main.main(Main.java:10)

错误含义与解决方法

这个错误属于编译期语法错误,核心原因是代码违反了Java语法规则,导致编译器无法正确解析代码的抽象语法树(AST)。

具体问题出在第10行的方法调用fungsiVoid( input: "apa pun");:

  • Java不支持命名参数的传参方式(即通过参数名指定传入值),只能按照方法定义的参数顺序直接传递参数值,不能添加input:这类参数名前缀。

修复后的调用代码应为:

fungsiVoid("apa pun");

当编译器遇到input:这种非Java标准语法的内容时,无法识别对应的语法结构,因此抛出"Erroneous tree type: "的错误,直白来说就是:编译器看不懂这段代码的写法,没法生成正确的代码结构。

内容的提问来源于stack exchange,提问作者Farhan Rizky Wahyudi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 14:14:59