假如这个CLASS 被我用des加密了,当然我能解密,但解密后的数据怎样加载呢?
解决方案 »
- 菜鸟请求援军急啊,
- 暑假里实在太无聊了,所以编了个贪吃蛇玩玩
- 请教JDBC连接oracle的问题.
- 新手请教:JAVA编程思想中的一个匿名类的例子,调试出错。谢谢。
- 【散分啦】Show Me The Money~~~ HOHO~~~
- 一个ZIP的问题
- how to convert a numeric String to integer
- 谁能给我java api的chm文档直接能下载的地址
- IO-字节(字符)缓冲流
- (请教高手)怎样只用APPLET实现一个图象和一个小动画一起出现而不闪烁?
- 初学JAVA 什么也不懂 老师就要我们做题 求大侠帮忙解决这个问题 --用列表来实现删除,添加等操作 谢谢了!
- 单项选择题
楼主去看看关于java类加载机制方面的资料吧。
貌似很有意思,怎么实现的,楼主说下啊.
不需要,你在自定义的classloader中将class的字节数组修改了即可,这个有一个自定义classloader的例子:
http://blog.chinaunix.net/u/32945/showart_255326.html
public Class findClass(String name)throws ClassNotFoundException
{
Class resultClass=null;
String pathName=name.replace('.','/');
byte[] data = loadClassData(pathName);
resultClass=defineClass(name, data, 0, data.length);
return resultClass;
}1:这个方法是怎样调用的
2:defineClass(String name, byte[] b, int off, int len) String name 这个参数是什么,看不懂
public static void main(String[] args) throws Exception { FileClassLoader loader = new FileClassLoader("D:/TestDir/t.jar"); Class objClass = loader.loadClass("com.TestClassLoader"); Class objClass2 = loader.loadClass("com.TestClassLoaderUse"); Object obj = objClass.newInstance(); //通过reflect执行函数..doit(String a); Method method=objClass.getMethod("doit",new Class[]{String.class}); System.out.println("method doit() return:"+method.invoke(obj,new Object[]{"J"})); System.out.println(objClass.getName()); System.out.println(objClass.getClassLoader()); }name就是你的class名称,如com.TestClassLoaderUse,com.x...
这样写的还是第一次看到中间的 !号啥意思 是固定写法?
{}这个方法在哪调用的还是没看到
loadClass
public Class loadClass(String name)
throws ClassNotFoundException
Loads the class with the specified name. This method searches for classes in the same manner as the loadClass(String, boolean) method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking loadClass(name, false).
Parameters:
name - The name of the class
Returns:
The resulting Class object
Throws:
ClassNotFoundException - If the class was not found--------------------------------------------------------------------------------loadClass
protected Class loadClass(String name,
boolean resolve)
throws ClassNotFoundException
Loads the class with the specified name. The default implementation of this method searches for classes in the following order: Invoke findLoadedClass(String) to check if the class has already been loaded. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead. Invoke the findClass(String) method to find the class. If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object. Subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.
Parameters:
name - The name of the class
resolve - If true then resolve the class
Returns:
The resulting Class object
Throws:
ClassNotFoundException - If the class could not be found