compiler.complieclass返回false(java.lang.compiler)

问题描述 投票:0回答:1

这里代码的目的是编译在.java文件上创建的类,以便可以判断用户输入是否正确。但是,该代码在每次试用时都会返回false。 导入java.lang。*;

/** * @author Joey */ public class NewCompTets { /** * @param args the command line arguments */ public static void main(String[] args) { NewCompTets cls = new NewCompTets(); NewCompTets subcls = new SubClass1(); // class CompilerDemo Class c = cls.getClass(); System.out.println(c); // sub class SubClass1 Class c1 = subcls.getClass(); System.out.println(c1); /* returns false if the compilation failed or no compiler is available */ boolean retval = Compiler.compileClass(c1); System.out.println("Return Value = " + retval); } } class SubClass1 extends NewCompTets { public static void test(){ System.out.print("2"); } }
    
java android jit java-compiler-api
1个回答
0
投票
我假设您始终需要首先编译父级,然后您可以编译子类课程,然后可以编译子类。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.