java.lang.ClassFormatError: Extra bytes at the end of class file
在精简JRE过程中,将rt.jar中类通过FileInputStream,FileOutputStream进行拷贝操作出错:
java.lang.ClassFormatError: Extra bytes at the end of class file
源代码:
- byte buf[] = new byte[256];
- while(fin.read(buf) != -1)
- {
- fout.write(buf);
- ir.read();
- }
- fout.flush();
修改后:
- byte buf[] = new byte[256];
- int len = 256;
- while((len = fin.read(buf)) != -1)
- {
- fout.write(buf,0,len);
- ir.read();
- }
- fout.flush();
相关资料:
java.lang.ClassFormatError
thrown when applet runs
Symptoms
When running an applet in a browser using the Sun JVM, a
ClassFormatError
is thrown by theClassLoader
. The same applet runs under the Microsoft VM.
Cause
This error is caused by bytecodes generated from old JDK 1.0.2/1.1 compilers, or from a third-party obfuscator. In the past, many of these compilers and obfuscators generated bytecode that does not conform to the Java VM Specification. Because the verifiers in recent J2SE releases are much stricter about bad class format, the
ClassFormatError
is thrown by the VM when these bad class files are loaded.Some typical problems in some older class files are the following (note that this list is not exhaustive):
- There are extra bytes at the end of the class file.
- The class file contains method or field names that do not begin with a letter.
- The class attempts to access private members of another class.
- The class file has other format errors, including illegal constant pool indices and illegal UTF-8 strings.
- The class file produced by an early (third-party) bytecode obfuscator violates proper class-file format.
Resolution
To allow some of the applets with bad class files to run in the Java 2 platform, Java Plug-in contains a bytecode transformer to transform some of the bad class files to good ones. Currently, only bad class files with the following problems may be transformed:
- Local variable name with a bad constant pool index
- Extra bytes at the end of the class file
- Code segment of the wrong length
- Illegal field/method name
- Illegal field/method modifiers
- Invalid start_pc/length in local var table
Unfortunately, the bytecode transformer cannot transform the following problems, which will still result in a
ClassFormatError
:
- Illegal use of nonvirtual function call
- Arguments can't fit into locals
- Unsorted lookup switch
- Truncated class file
You can resolve these problems by simply recompiling your Java classes with the
javac
compiler from the Java 2 SDK. If you choose to use a third-party obfuscator, be sure to use one that produces class files that respect proper class-file format.
java.lang.ClassFormatError: Extra bytes at the end of class file的更多相关文章
- 阿里巴巴 fastjson-1.2.12.jar json解析异常java.lang.ClassFormatError: Invalid method Code length 66865 in class file com/alibaba/fastjson/serializer/ASMSerializer_6_UserKdlb
承接上篇:fastjson反序列化LocalDateTime失败的问题java.time.format.DateTimeParseException: Text '2019-05-24 13:52:1 ...
- java.lang.ClassFormatError: Illegal UTF8 string in constant pool in class file Server/Request
Linux服务器上,将本地编译好的文件上传后,Tomcat启动时报错: Exception in thread "Thread-2" java.lang.ClassFormatEr ...
- IZ65534: 'JAVA.LANG.CLASSFORMATERROR' ERROR FOR A VALID IDENTIFIER
PAR status Closed as program error. Error description Error Message: The java class could not be loa ...
- java.lang.ClassFormatError
Error occurred during initialization of VMjava.lang.ClassFormatError: Unknown constant tag 26 in cla ...
- java.lang.ClassFormatError Duplicate field name&signature in class file XXXXXX【转】
本文转载自:https://blog.csdn.net/ylchou/article/details/7739742 2012-7-5 15:06:25org.apache.catalina.core ...
- spring运行时没有问题,在单元测试时,出现java.lang.ClassFormatError错误
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstrac ...
- java.lang.ClassFormatError: Unknown constant tag 0 in class file
在通过文件上传之后,运行java程序,突然发现这么一个错误:java.lang.ClassFormatError: Unknown constant tag 0 in class file,通过网上查 ...
- java.lang.ClassFormatError: Trjava.lang.ClassFormatError: Truncated class fileuncated class file
周末过来加班,上传编译好的文件后,部署到服务器没事.但是服务器日志满了,把日志清除后,把服务启动,发现报这个错误,大致网上看了一下,这个错误是编译的文件损坏了.然后大致看了一下文件,还真是.由于日志满 ...
- java.lang.ClassFormatError: Truncated class file
之前跑的很好的程序,因为我本地IDE出了问题的原因,倒是编译的错误的class文件,结果点击的时候报这样的错误,后来重新clean了工程,重新打包解压启动,问题依旧. 解决办法: 把tomcat的wo ...
随机推荐
- [置顶]
Android 状态栏那些小坑?
背景:因为之前老板上次问我我们的app能不能自定义上面的状态栏我说可以啊!当时没管,今天试了下果然很多坑,之前github上也有很多大佬写了一个开源库有兴趣的可以点进去看下支持DrawLayout沉侵 ...
- 正则 匹配 HTML 标签
var tt=((result.data).toString()).match(/<style(([\s\S])*?)<\/style>/g);
- iOS 解决上传100张图片内存奔溃问题
最近项目需求,从相册中提取100张图片,然后上传到服务器.前提是图片不能压缩.因为要将图片信息采集出来制作出3D模型.所以必须是高清图片. 先看下代码 [NetWorking uploadWithUr ...
- 原 the app referencesnon-public selectors in payload
摘要 当我们上传验证的时候,出现了the app referencesnon-public selectors in payload/项目名.app/项目:字符 的警告的解决办法 当我们上传验证的时候 ...
- Java并发--并发容器之ConcurrentHashMap
下面这部分内容转载自: http://www.haogongju.net/art/2350374 JDK5中添加了新的concurrent包,相对同步容器而言,并发容器通过一些机制改进了并发性能.因为 ...
- 从hello world 说程序运行机制
转自:http://www.cnblogs.com/yanlingyin/archive/2012/03/05/2379199.html 开篇 学习任何一门编程语言,都会从hello world 开始 ...
- Spring boot admin 使用
1. maven依赖 <dependencies> <dependency> <groupId>org.springframework.boot</group ...
- MyEclipse自动生成Ant Build.xm
关于MyEclipse 自动生成 Ant Build.xml 配置文件,生成的方法很隐蔽,是自己无意中找到的.选择你要生成Build.xml文件的项目,右键. Export-> General ...
- C# Socket Post File
///<summary> ///向服务器发送混合型的请求,1:成功发送,0:发送失败 ///</summary> ///<param name="paranam ...
- Windows运行命令集锦
开始菜单中的“运行”(Win+R)是通向程序的快捷途径,输入特定的命令后,即可快速的打开Windows的大部分程序,熟练的运用它,将给我们的操作带来诸多便捷. winver 检查Windows版本 ...