在编译时使用自定义类加载器 [英] Use a custom classloader at compile time

查看:227
本文介绍了在编译时使用自定义类加载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为javac(或某些替代java编译器)指定自定义类加载器?

Is it possible to specify a custom classloader for javac (or some alternative java compiler)?

我喜欢这样的专长,因为它可以让我编译使用只能由我的特殊类加载器找到的类的类。

I'd love such a feat because it would allow me to compile classes that use classes that are only found by my special classloader.

对于好奇的人:我会编写一个连接数据库并根据找到的表创建类的类。

For the curious ones: I'd write a classloder that connects to a database and creates classes based on the tables it finds.

推荐答案

当你运行javac时,可以像这样指定类加载器:

When you run javac you can specify the classloader like so:

javac -J-Djava.system.class.loader=org.awesome.classloader sourcefile.java

这篇关于在编译时使用自定义类加载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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