编译缺少代码部分的Java类 [英] Compile Java class with missing code parts

查看:340
本文介绍了编译缺少代码部分的Java类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一些想法如何编译Java代码与其他一些代码缺失(方法调用)。我完全知道javac将不允许你编译Java文件,如果找不到所有的依赖。但是也许有一些方法如何绕过它,像强制编译。

我的字节码知识不是那么好,但我认为一些方法invoke只是完全包定义类和方法名称与参数。所以如果编译器只是把这个数据到类文件,并假设在运行过程依赖将可用(如果不是简单的NoSuchMethodExp)。

I'm looking for some ideas on how to compile Java code with some other pieces of code missing (method calls). I am fully aware that javac will not allow you to compile Java files if cannot find all dependencies. But maybe there is some way how to bypass it, something like force compile.
My bytecode knowledge is not so good but I think some method invoke is just full package definition of class and method name with parameters. So if compiler just puts this data to class file and assume in running process dependency will be available (if not simple NoSuchMethodExp).

只有解决方法到目前为止我发现是创建空缺少类文件与空方法欺骗编译器。工作完美,但应该有更容易的方法:)

任何想法?

Only workaround so far I found is to create empty missing class files with empty methods to "cheat" compiler. Works perfectly but there should be easier way :)
Any ideas?

推荐答案

一个jar,你可以提取你没有修改到另一个目录的类文件,并包括在类路径中。这样他们就可以使用编译器。

If you're modifying a jar, you can extract the class files you are not modifying to another directory and include that in the classpath. That way they will be available to the compiler.

这篇关于编译缺少代码部分的Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆