免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: huangmw
打印 上一主题 下一主题

jsp中下载程序问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2002-10-18 16:39 |只看该作者

jsp中下载程序问题

谈谈JAVA的反编译

谈谈JAVA的反编译
于瑶
如今JAVA语言在全世界范围正如火如荼般的流行,它广范地应用在INTERNET的数据库、多媒体、CGI、及动态网页的制作方面。1999年在美国对JAVA程序员的需求量首次超过C++!
作者因最近分析一些JAVA程序,对JAVA的反编译进行了一番了解,下面将我所了解的情况作以下介绍,希望对JAVA爱好者有所帮助。
JAVA是采用一种称做“字节编码”的程序结构,分为小程序(嵌入到HTML文件中)和应用程序(直接在命令状态下执行)两种类型。无论哪种结构,一旦用JAVAC 命令编译后,均变成后缀为CLASS的同名可执行文件。这种文件是不可阅读的代码。
经查阅了SUN公司的JDK(JDK1.1.3)文档资料后,我找到了一个据称是可反编译JAVA的JAVAP文件(EXE),这个文件位于\JDK\BIN\ 下面,经按说明使用后,感到失望,原来这个“反编译”仅可反编译出JAVA程序的数据区(定义)、若干方法和类的引用等。
这里我用了一个简单例子来说明问题。
JAVA的源程序hello_java.java如下:

import java.applet.*&#59;
import java.awt.*&#59;

public class hello_java extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello Java!\n",20,20)&#59;
}
}

经用反编译命令:javap -c -package -public -private hello_java hello.java
得到的反编译结果(hello.java)如下:(有关javap命令的选择参数请见其使用说明,这里-c表示选择了反编译)

Compiled from hello_java.java
public synchronized class hello_java extends java.applet.Applet
/* ACC_SUPER bit set */
{
public void paint(java.awt.Graphics)&#59;
public hello_java()&#59;

Method void paint(java.awt.Graphics)
0 aload_1
1 ldc #1 <String &quot;Hello Java!
&quot;>;
3 bipush 20
5 bipush 20
7 invokevirtual #6 <Method java.awt.Graphics.drawString(Ljava/lang/String&#59;II)V>;
10 return

Method hello_java()
0 aload_0
1 invokespecial #5 <Method java.applet.Applet.<init>;()V>;
4 return
}

从上述结果不难看出该反编译未能将源程序全译出来,像语句g.drawString(&quot;Hello Java!\n&quot;,20,20)&#59; 就没有。随着程序量增加,未能编译的JAVA语句还会更多。所以这个反编译程序仅能起个参考作用。
幸亏有了INTERNET,笔者通过YAHOO很快找到了一个JAVA反编译“自由软件”(SHAREWARE),http://www.inter.nl.net/users/H.P.van.Vliet/mocha.htm 。 这个软件叫MOCHA,据说是一位30来岁的加拿大的研究生所完成,仅是个“?”版,原因是这位叫做H.P.VAN.VLIET的小伙子患癌逝世了,十分可惜呀!
经使用MOCHA反编译软件,感到这个软件十分好用,笔者试反编译多个JAVA程序,均得到很好的结果。
这里给出如何使用这个软件,首先,用WINZIP等将&quot;mocha-b1.zip&quot; 解开得到&quot;mocha.zip&quot;文件,&quot;mocha.zip&quot;不须再解开,这个包内包括了反编译的类文件,只需将其拷贝到JDK所在的目录下,如:c:\jdk\bin\ 此外,须设置路径:SET CLASSPATH=c:\myclasses&#59;c:\jdk\bin\mocha.zip
MOCHA用法:
java mocha.Decompiler [-v] [-o] Class1.class Class2.class ...
&quot;java&quot; 调用Java虚拟机
&quot;mocha.Decompiler&quot; 指示要进行JAVA反编译
&quot;-v&quot; 选择详细输出
&quot;-o&quot; 选写入已有的.mocha 文件
&quot;ClassX.class&quot; 指出要反编译类名
注意,不需给出输出的JAVA文件名,因为MOCHA自动产生一个与CLASS同名但扩展名为MOCHA的JAVA源文件。
对于上例,可用命令:
java mocha.Decompiler [-v] [-o] hello_java.class
得到的源文件:
/* Decompiled by Mocha from hello_java.class */
/* Originally compiled from hello_java.java */

import java.applet.Applet&#59;
import java.awt.Graphics&#59;

public synchronized class hello_java extends Applet
{
public void paint(Graphics g)
{
g.drawString(&quot;Hello Java!\n&quot;, 20, 20)&#59;
}

public hello_java()
{
}
}
我们不难发现,此文件与编译前的JAVA源文件完全一样!笔者曾经用MOCHA反编译出最大为80K的源文件,均取得成功。
在此,笔者向英年早逝的VLIET表示敬意,感谢他给我们留下这个工具软件。
如读者下载MOCHA有困难,可给笔者来电子邮件,笔者可将MOCHA寄去。

参考文献:
1) http://www.inter.nl.net/users/H.P.van.Vliet/mocha.htm
2) http://www.javasoft.com
3) http://java.sun.com
4) http://www.yahoo.com

论坛徽章:
0
12 [报告]
发表于 2002-10-18 16:49 |只看该作者

jsp中下载程序问题

[这个贴子最后由eclipse在 2002/10/18 04:55pm 编辑]

具体的反编译工具推荐Cavaj,下载地址:http://www.bysoft.se/sureshot/cavaj/cavajdemo.zip

论坛徽章:
0
13 [报告]
发表于 2002-11-30 22:17 |只看该作者

jsp中下载程序问题

谢谢。。
错误信息:
javazoom.upload.UploadException: Database store error:There is not enough procedure cache to run this procedure, trigger, or SQL batch. Retry later, or ask your SA to reconfigure SQL Server with more procedure cache.
.5 Configuring JDBC connection caches
For JDBC connection caches using jConnect(TM) for JDBC(TM), the
property is enabled by default, so that prepared statements are translated to temporary stored

procedures. This can increase performance when prepared statements are executed more than once.

However, this setting also increases use of the Adaptive Server Enterprise procedure cache space.

If the procedure cache is too small, you may see this exception in the server log file:

javax.ejb.EJBException: nested exception is:com.sybase.jdbc2.jdbc.SybSQLException: There is not

enough procedure cache to run this procedure, trigger, or SQL batch. Retry later, or ask your SA

to reconfigure SQL Server with more procedure cache
To solve this problem, you can do one of the following:
Edit the connection cache properties. On the All Properties tab, set the value of the

DYNAMIC_PREPARE property to

false
, or add the property if it does not already exist:
DYNAMIC_PREPARE=false

sybase中我怎样改写啊。。。。??
Increase the size of the procedure cache. The size required depends on the number of database

connections and the number of prepared statements used. See the Adaptive Server Enterprise

documentation for more information


论坛徽章:
0
14 [报告]
发表于 2002-12-24 11:18 |只看该作者

jsp中下载程序问题

能不能简要介绍一下你的smartdown的实现下载的原理阿。谢谢阿。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP