请教:java反射机制无法找到android中的类

时间:2022-09-30 14:02:00
想用java的反射机制打印android应用软件代码的类结构。把应用软件的jar包和android的jar包都加进去之后,自己的类可以分析,但是遇到class XXX extends Service这种的时候,就出现异常,Exception in thread "main" java.lang.NoClassDefFoundError: android/app/Service。但是如果catch了这个异常,执行之后就会出现
=============== DEBUG MESSAGE: illegal bytecode sequence - method not verified ================

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_PRIV_INSTRUCTION (0xc0000096) at pc=0x009526e1, pid=2664, tid=2944
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) Client VM (19.1-b02 mixed mode windows-x86 )
# Problematic frame:
# j  com.sohu.util.Base64.<clinit>()V+2
#
# An error report file with more information is saved as:
# C:\Documents and Settings\Administrator\workspace\Test1\hs_err_pid2664.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#


请问这个问题应该如何解决!万分感谢!

5 个解决方案

#1


换个 jvm ,比如用最新的。

#2


hs_err_pid2664.log中什么内容?不妨贴出来。。
看你catch的错误时找不到类。外部引入的jar包哪个没找到

#3


illegal bytecode sequence

字节码顺序不对

#4


log就是这样,看不懂。。。

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_PRIV_INSTRUCTION (0xc0000096) at pc=0x009526e1, pid=6016, tid=4036
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) Client VM (19.1-b02 mixed mode windows-x86 )
# Problematic frame:
# j  cn.com.opda.opdatools.util.DxCode.<clinit>()V+2
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x00847400):  JavaThread "main" [_thread_in_Java, id=4036, stack(0x008d0000,0x00920000)]

siginfo: ExceptionCode=0xc0000096

Registers:
EAX=0x00000000, EBX=0x00000056, ECX=0x00000008, EDX=0x00930000
ESP=0x0091f7ec, EBP=0x0091f840, ESI=0x12d02ec7, EDI=0x0091f84c
EIP=0x009526e1, EFLAGS=0x00010216

Register to memory mapping:

EAX=0x00000000
0x00000000 is pointing to unknown location

EBX=0x00000056
0x00000056 is pointing to unknown location

ECX=0x00000008
0x00000008 is pointing to unknown location

EDX=0x00930000
0x00930000 is pointing to unknown location

ESP=0x0091f7ec
0x0091f7ec is pointing into the stack for thread: 0x00847400
"main" prio=6 tid=0x00847400 nid=0xfc4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

EBP=0x0091f840
0x0091f840 is pointing into the stack for thread: 0x00847400
"main" prio=6 tid=0x00847400 nid=0xfc4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

ESI=0x12d02ec7
{constMethod} 
 - klass: {other class}
 - method:       0x12d02f38 {method} '<clinit>' '()V' in 'cn/com/opda/opdatools/util/DxCode'
 - exceptions:   0x129d11e8
bci_from(12D02EC7) = 7; print_codes():

EDI=0x0091f84c
0x0091f84c is pointing into the stack for thread: 0x00847400
"main" prio=6 tid=0x00847400 nid=0xfc4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE


Top of Stack: (sp=0x0091f7ec)
0x0091f7ec:   0091f84c 12d02ec7 0091f840 0091f80c
0x0091f7fc:   00000056 0000000f 00000008 00000000
0x0091f80c:   009526db 6da30898 00000000 02b1af60
0x0091f81c:   02b1af60 0091f820 12d02ec2 0091f84c
0x0091f82c:   12d03648 00000000 12d02f38 00000000
0x0091f83c:   0091f850 0091f868 00950364 00000000
0x0091f84c:   00000000 0091f878 6d8e038e 00001f80
0x0091f85c:   009502ff 00847400 12d02f38 0091f8e0 

Instructions: (pc=0x009526e1)
0x009526d1:   68 98 08 a3 6d e8 00 00 00 00 60 e8 bf 03 eb 6c
0x009526e1:   f4 66 90 00 00 00 00 00 00 00 00 00 00 00 00 c0 


Stack: [0x008d0000,0x00920000],  sp=0x0091f7ec,  free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
j  cn.com.opda.opdatools.util.DxCode.<clinit>()V+2
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf0ab9]
V  [jvm.dll+0x1837d1]
V  [jvm.dll+0xf0b3d]
V  [jvm.dll+0xe15d7]
V  [jvm.dll+0xe183e]
V  [jvm.dll+0xe1b29]
V  [jvm.dll+0xe1c46]
V  [jvm.dll+0x118969]
V  [jvm.dll+0x12068f]
C  [java.dll+0x13bc]
j  java.lang.Class.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;+0
j  java.lang.Class.forName(Ljava/lang/String;)Ljava/lang/Class;+5
j  ZhaoYang.ReflectionTest.printName(Ljava/lang/String;Ljava/util/ArrayList;)Ljava/util/ArrayList;+3
j  ZhaoYang.SearchMethod.search(Ljava/lang/String;)Ljava/util/ArrayList;+141
j  ZhaoYang.SearchMethod.searchMethod(Ljava/lang/String;Ljava/lang/String;)Ljava/util/ArrayList;+47
j  ZhaoYang.SearchMethod.main([Ljava/lang/String;)V+61
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf0ab9]
V  [jvm.dll+0x1837d1]
V  [jvm.dll+0xf0b3d]
V  [jvm.dll+0xfa0d6]
V  [jvm.dll+0x101cde]
C  [javaw.exe+0x2155]
C  [javaw.exe+0x8614]
C  [kernel32.dll+0xb729]


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x16bb0800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=5896, stack(0x16df0000,0x16e40000)]
  0x16ba2000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2520, stack(0x16da0000,0x16df0000)]
  0x16b9d400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5864, stack(0x16d50000,0x16da0000)]
  0x16bb5800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4576, stack(0x16d00000,0x16d50000)]
  0x16b8b800 JavaThread "Finalizer" daemon [_thread_blocked, id=2604, stack(0x16cb0000,0x16d00000)]
  0x16b86c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=3300, stack(0x16c60000,0x16cb0000)]
=>0x00847400 JavaThread "main" [_thread_in_Java, id=4036, stack(0x008d0000,0x00920000)]

Other Threads:
  0x16b83000 VMThread [stack: 0x16c10000,0x16c60000] [id=4144]
  0x16bb3000 WatcherThread [stack: 0x16e40000,0x16e90000] [id=4812]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 4928K, used 1400K [0x029d0000, 0x02f20000, 0x07f20000)
  eden space 4416K,  31% used [0x029d0000, 0x02b28f50, 0x02e20000)
  from space 512K,   3% used [0x02ea0000, 0x02ea51d0, 0x02f20000)
  to   space 512K,   0% used [0x02e20000, 0x02e20000, 0x02ea0000)
 tenured generation   total 10944K, used 285K [0x07f20000, 0x089d0000, 0x129d0000)
   the space 10944K,   2% used [0x07f20000, 0x07f67518, 0x07f67600, 0x089d0000)
 compacting perm gen  total 12288K, used 3277K [0x129d0000, 0x135d0000, 0x169d0000)
   the space 12288K,  26% used [0x129d0000, 0x12d03740, 0x12d03800, 0x135d0000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x00424000  C:\Program Files\Java\jre6\bin\javaw.exe
0x7c920000 - 0x7c9b6000  C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c91e000  C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e49000  C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee3000  C:\WINDOWS\system32\RPCRT4.dll
0x77fc0000 - 0x77fd1000  C:\WINDOWS\system32\Secur32.dll
0x77d10000 - 0x77da0000  C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f39000  C:\WINDOWS\system32\GDI32.dll
0x76300000 - 0x7631d000  C:\WINDOWS\system32\IMM32.DLL
0x62c20000 - 0x62c29000  C:\WINDOWS\system32\LPK.DLL
0x73fa0000 - 0x7400b000  C:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000  C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da96000  C:\Program Files\Java\jre6\bin\client\jvm.dll
0x76b10000 - 0x76b3a000  C:\WINDOWS\system32\WINMM.dll
0x6d7a0000 - 0x6d7ac000  C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000  C:\Program Files\Java\jre6\bin\java.dll
0x6d280000 - 0x6d288000  C:\Program Files\Java\jre6\bin\hpi.dll
0x76bc0000 - 0x76bcb000  C:\WINDOWS\system32\PSAPI.DLL
0x6d7e0000 - 0x6d7ef000  C:\Program Files\Java\jre6\bin\zip.dll

VM Arguments:
jvm_args: -Dfile.encoding=GBK -Xbootclasspath/p:D:\ZhaoYang\myjar\classes.dex.dex2jar.jar 
java_command: ZhaoYang.SearchMethod
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
CLASSPATH=.;C:\Program Files\Java\jdk1.6.0_24\lib;C:\Program Files\Java\jdk1.6.0_24\lib\tools.jar;d:\ZhaoYang\myjar\test.jar
PATH=C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;D:\ZhaoYang\download\ultraedit\UltraEdit-32 V16.10.0.1028 官方简体中文版\IDM Computer Solutions\UltraEdit\;C:\Program Files\Java\jdk1.6.0_24\jre\bin;C:\Program Files\Java\jdk1.6.0_24\bin;C:\Program Files\eclipse;
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 3

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3

Memory: 4k page, physical 2071792k(650680k free), swap 4009840k(2344008k free)

vm_info: Java HotSpot(TM) Client VM (19.1-b02) for windows-x86 JRE (1.6.0_24-b07), built on Feb  2 2011 17:44:41 by "java_re" with MS VC++ 7.1 (VS2003)

time: Wed Aug 17 13:35:18 2011
elapsed time: 1 seconds

#5


Exception in thread "main" java.lang.NoClassDefFoundError: android/app/Service

是不是没有这个类

#1


换个 jvm ,比如用最新的。

#2


hs_err_pid2664.log中什么内容?不妨贴出来。。
看你catch的错误时找不到类。外部引入的jar包哪个没找到

#3


illegal bytecode sequence

字节码顺序不对

#4


log就是这样,看不懂。。。

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_PRIV_INSTRUCTION (0xc0000096) at pc=0x009526e1, pid=6016, tid=4036
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) Client VM (19.1-b02 mixed mode windows-x86 )
# Problematic frame:
# j  cn.com.opda.opdatools.util.DxCode.<clinit>()V+2
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x00847400):  JavaThread "main" [_thread_in_Java, id=4036, stack(0x008d0000,0x00920000)]

siginfo: ExceptionCode=0xc0000096

Registers:
EAX=0x00000000, EBX=0x00000056, ECX=0x00000008, EDX=0x00930000
ESP=0x0091f7ec, EBP=0x0091f840, ESI=0x12d02ec7, EDI=0x0091f84c
EIP=0x009526e1, EFLAGS=0x00010216

Register to memory mapping:

EAX=0x00000000
0x00000000 is pointing to unknown location

EBX=0x00000056
0x00000056 is pointing to unknown location

ECX=0x00000008
0x00000008 is pointing to unknown location

EDX=0x00930000
0x00930000 is pointing to unknown location

ESP=0x0091f7ec
0x0091f7ec is pointing into the stack for thread: 0x00847400
"main" prio=6 tid=0x00847400 nid=0xfc4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

EBP=0x0091f840
0x0091f840 is pointing into the stack for thread: 0x00847400
"main" prio=6 tid=0x00847400 nid=0xfc4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

ESI=0x12d02ec7
{constMethod} 
 - klass: {other class}
 - method:       0x12d02f38 {method} '<clinit>' '()V' in 'cn/com/opda/opdatools/util/DxCode'
 - exceptions:   0x129d11e8
bci_from(12D02EC7) = 7; print_codes():

EDI=0x0091f84c
0x0091f84c is pointing into the stack for thread: 0x00847400
"main" prio=6 tid=0x00847400 nid=0xfc4 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE


Top of Stack: (sp=0x0091f7ec)
0x0091f7ec:   0091f84c 12d02ec7 0091f840 0091f80c
0x0091f7fc:   00000056 0000000f 00000008 00000000
0x0091f80c:   009526db 6da30898 00000000 02b1af60
0x0091f81c:   02b1af60 0091f820 12d02ec2 0091f84c
0x0091f82c:   12d03648 00000000 12d02f38 00000000
0x0091f83c:   0091f850 0091f868 00950364 00000000
0x0091f84c:   00000000 0091f878 6d8e038e 00001f80
0x0091f85c:   009502ff 00847400 12d02f38 0091f8e0 

Instructions: (pc=0x009526e1)
0x009526d1:   68 98 08 a3 6d e8 00 00 00 00 60 e8 bf 03 eb 6c
0x009526e1:   f4 66 90 00 00 00 00 00 00 00 00 00 00 00 00 c0 


Stack: [0x008d0000,0x00920000],  sp=0x0091f7ec,  free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
j  cn.com.opda.opdatools.util.DxCode.<clinit>()V+2
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf0ab9]
V  [jvm.dll+0x1837d1]
V  [jvm.dll+0xf0b3d]
V  [jvm.dll+0xe15d7]
V  [jvm.dll+0xe183e]
V  [jvm.dll+0xe1b29]
V  [jvm.dll+0xe1c46]
V  [jvm.dll+0x118969]
V  [jvm.dll+0x12068f]
C  [java.dll+0x13bc]
j  java.lang.Class.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;+0
j  java.lang.Class.forName(Ljava/lang/String;)Ljava/lang/Class;+5
j  ZhaoYang.ReflectionTest.printName(Ljava/lang/String;Ljava/util/ArrayList;)Ljava/util/ArrayList;+3
j  ZhaoYang.SearchMethod.search(Ljava/lang/String;)Ljava/util/ArrayList;+141
j  ZhaoYang.SearchMethod.searchMethod(Ljava/lang/String;Ljava/lang/String;)Ljava/util/ArrayList;+47
j  ZhaoYang.SearchMethod.main([Ljava/lang/String;)V+61
v  ~StubRoutines::call_stub
V  [jvm.dll+0xf0ab9]
V  [jvm.dll+0x1837d1]
V  [jvm.dll+0xf0b3d]
V  [jvm.dll+0xfa0d6]
V  [jvm.dll+0x101cde]
C  [javaw.exe+0x2155]
C  [javaw.exe+0x8614]
C  [kernel32.dll+0xb729]


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x16bb0800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=5896, stack(0x16df0000,0x16e40000)]
  0x16ba2000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2520, stack(0x16da0000,0x16df0000)]
  0x16b9d400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5864, stack(0x16d50000,0x16da0000)]
  0x16bb5800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4576, stack(0x16d00000,0x16d50000)]
  0x16b8b800 JavaThread "Finalizer" daemon [_thread_blocked, id=2604, stack(0x16cb0000,0x16d00000)]
  0x16b86c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=3300, stack(0x16c60000,0x16cb0000)]
=>0x00847400 JavaThread "main" [_thread_in_Java, id=4036, stack(0x008d0000,0x00920000)]

Other Threads:
  0x16b83000 VMThread [stack: 0x16c10000,0x16c60000] [id=4144]
  0x16bb3000 WatcherThread [stack: 0x16e40000,0x16e90000] [id=4812]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 4928K, used 1400K [0x029d0000, 0x02f20000, 0x07f20000)
  eden space 4416K,  31% used [0x029d0000, 0x02b28f50, 0x02e20000)
  from space 512K,   3% used [0x02ea0000, 0x02ea51d0, 0x02f20000)
  to   space 512K,   0% used [0x02e20000, 0x02e20000, 0x02ea0000)
 tenured generation   total 10944K, used 285K [0x07f20000, 0x089d0000, 0x129d0000)
   the space 10944K,   2% used [0x07f20000, 0x07f67518, 0x07f67600, 0x089d0000)
 compacting perm gen  total 12288K, used 3277K [0x129d0000, 0x135d0000, 0x169d0000)
   the space 12288K,  26% used [0x129d0000, 0x12d03740, 0x12d03800, 0x135d0000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x00424000  C:\Program Files\Java\jre6\bin\javaw.exe
0x7c920000 - 0x7c9b6000  C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c91e000  C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e49000  C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee3000  C:\WINDOWS\system32\RPCRT4.dll
0x77fc0000 - 0x77fd1000  C:\WINDOWS\system32\Secur32.dll
0x77d10000 - 0x77da0000  C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f39000  C:\WINDOWS\system32\GDI32.dll
0x76300000 - 0x7631d000  C:\WINDOWS\system32\IMM32.DLL
0x62c20000 - 0x62c29000  C:\WINDOWS\system32\LPK.DLL
0x73fa0000 - 0x7400b000  C:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000  C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da96000  C:\Program Files\Java\jre6\bin\client\jvm.dll
0x76b10000 - 0x76b3a000  C:\WINDOWS\system32\WINMM.dll
0x6d7a0000 - 0x6d7ac000  C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000  C:\Program Files\Java\jre6\bin\java.dll
0x6d280000 - 0x6d288000  C:\Program Files\Java\jre6\bin\hpi.dll
0x76bc0000 - 0x76bcb000  C:\WINDOWS\system32\PSAPI.DLL
0x6d7e0000 - 0x6d7ef000  C:\Program Files\Java\jre6\bin\zip.dll

VM Arguments:
jvm_args: -Dfile.encoding=GBK -Xbootclasspath/p:D:\ZhaoYang\myjar\classes.dex.dex2jar.jar 
java_command: ZhaoYang.SearchMethod
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
CLASSPATH=.;C:\Program Files\Java\jdk1.6.0_24\lib;C:\Program Files\Java\jdk1.6.0_24\lib\tools.jar;d:\ZhaoYang\myjar\test.jar
PATH=C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;D:\ZhaoYang\download\ultraedit\UltraEdit-32 V16.10.0.1028 官方简体中文版\IDM Computer Solutions\UltraEdit\;C:\Program Files\Java\jdk1.6.0_24\jre\bin;C:\Program Files\Java\jdk1.6.0_24\bin;C:\Program Files\eclipse;
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 3

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3

Memory: 4k page, physical 2071792k(650680k free), swap 4009840k(2344008k free)

vm_info: Java HotSpot(TM) Client VM (19.1-b02) for windows-x86 JRE (1.6.0_24-b07), built on Feb  2 2011 17:44:41 by "java_re" with MS VC++ 7.1 (VS2003)

time: Wed Aug 17 13:35:18 2011
elapsed time: 1 seconds

#5


Exception in thread "main" java.lang.NoClassDefFoundError: android/app/Service

是不是没有这个类