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
ClassFormatErroris 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
ClassFormatErroris 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
javaccompiler 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 ...
随机推荐
- IPv4地址范围和一些小知识
IP地址范围: 保留地址(私有IP地址): 10.0.0.0——10.255.255.255 172.16.0.0——172.31.255.255 192.168.0.0——192.1 ...
- 深入理解java虚拟机-第13章-线程安全与锁优化
第十三章 线程安全与锁优化 线程安全 java语言中的线程安全 1 不可变.Immutable 的对象一定是线程安全的 2 绝对线程安全 一个类要达到不管运行时环境如何,调用者都不需要额外的同步措施, ...
- BZOJ1816 Cqoi2010 扑克牌【二分答案】
BZOJ1816 Cqoi2010 扑克牌 Description 你有n种牌,第i种牌的数目为ci.另外有一种特殊的牌:joker,它的数目是m.你可以用每种牌各一张来组成一套牌,也可以用一张jok ...
- JavaWeb向浏览器返回一个音频流
浏览器直接播放音频文件,1是直接访问一个html的音频文件,,2 是返回一个Java音频流给浏览器解析. 下面实现一个java的wav文件音频流,可以直接播放音频文件 package org.lib. ...
- Scrapy源码研究前戏
一.Twisted的使用 在 Twisted 中,有一种特殊的对象用于实现事件循环.这个对象叫做 reactor.可以把反应器(reactor)想象为 Twisted 程序的中枢神经.除了分发事件循环 ...
- AppScan9.0.3.5漏洞扫描记录
1.跨站点脚本编制 这个安全漏洞拿cookie做文章,而且是将前端的一些弹窗方法,要么通过脚本注入,要么通过url.encode之后注入,看几个变异的版本: 版本一: cookie 从以下位置进行控 ...
- c++重在运算符前置自增和后置自增
class student { int age; }; int main() { class student stu; (stu++)++;//error ++(stu++);//error stu+ ...
- (转)Android内存泄漏分析及调试
http://blog.csdn.net/gemmem/article/details/13017999 此文承接我的另一篇文章:Android进程的内存管理分析 首先了解一下dalvik的Ga ...
- 笔记本设置wifi热点并抓包
现在很多人喜欢蹭wifi热点,这里演示一下怎么利用笔记本设置wifi热点来钓鱼.本机是win10操作系统. 一.设置笔记wifi热点:右键点击右下角网络图标 -> 打开“网络和Internet设 ...
- ASP.NET比较常用的26个性能优化技巧
1. 数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源.ASP.NET中提供了连接池( ...