标签:java输出类名
在上一篇博文中提到javaagent可以在执行main方法之前输出内容,这一篇我们仍然用它在 Java SE 5 及其后续版本当中,开发者可以在一个普通 Java 程序(带有 main 函数的 Java 类)运行时,通过 –javaagent 参数指定一个特定的 jar 文件(包含 Instrumentation 代理)来启动 Instrumentation 的代理程序。在类的字节码载入jvm前会调用ClassFileTransformer的transform方法,从而实现修改原类方法的功能
使用方法如下,在premain方法中使用如下语句
inst.addTransformer(new ClassNameTransformer());
其中ClassNameTransformer实现了ClassFileTransformer,并重写transform方法
下面的例子使用这个方式输出所有类名
新建名为ClassNameAgent的项目,结构如下
ClassNameAgent.java文件内容
package com.vvvtimes.demo.agent; import java.lang.instrument.Instrumentation; public class ClassNameAgent { public static void premain(String agentOps, Instrumentation inst) { try { inst.addTransformer(new ClassNameTransformer()); } catch (Exception e) { e.printStackTrace(); } } }
ClassNameTransformer.java文件内容
package com.vvvtimes.demo.agent; import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.IllegalClassFormatException; import java.security.ProtectionDomain; public class ClassNameTransformer implements ClassFileTransformer { @Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { System.out.println(className); return null; } }
MANIFEST.MF文件内容
Manifest-Version: 1.0 Premain-Class: com.vvvtimes.demo.agent.ClassNameAgent Can-Redefine-Classes: true
导出为ClassNameAgent.jar
将动态生成类的博文中的代码导出可运行jar,命名为DynamicGenerateClass.jar
放到同一目录执行命令
java -javaagent:ClassNameAgent.jar -jar DynamicGenerateClass.jar
执行结果
C:\Users\admin\Desktop>java -javaagent:ClassNameAgent.jar -jar DynamicGenerateClass.jar java/lang/invoke/MethodHandleImpl java/lang/invoke/MethodHandleImpl$1 java/lang/invoke/MethodHandleImpl$2 java/util/function/Function java/lang/invoke/MethodHandleImpl$3 java/lang/invoke/MethodHandleImpl$4 java/lang/ClassValue java/lang/ClassValue$Entry java/lang/ClassValue$Identity java/lang/ClassValue$Version java/lang/invoke/MemberName$Factory java/lang/invoke/MethodHandleStatics java/lang/invoke/MethodHandleStatics$1 sun/misc/PostVMInitHook sun/usagetracker/UsageTrackerClient java/util/concurrent/atomic/AtomicBoolean sun/usagetracker/UsageTrackerClient$1 sun/usagetracker/UsageTrackerClient$4 sun/usagetracker/UsageTrackerClient$2 java/lang/ProcessEnvironment java/lang/ProcessEnvironment$NameComparator java/lang/ProcessEnvironment$EntryComparator java/util/Collections$UnmodifiableMap java/lang/ProcessEnvironment$CheckedEntrySet java/util/HashMap$EntrySet java/lang/ProcessEnvironment$CheckedEntrySet$1 java/util/HashMap$EntryIterator java/util/HashMap$HashIterator java/lang/ProcessEnvironment$CheckedEntry sun/usagetracker/UsageTrackerClient$3 java/io/FileOutputStream$1 sun/launcher/LauncherHelper com/vvvtimes/DynamicGenerateClass sun/launcher/LauncherHelper$FXHelper java/lang/Class$MethodArray java/lang/Void sun/security/util/SignatureFileVerifier java/security/CryptoPrimitive java/util/EnumSet java/lang/Class$4 java/util/RegularEnumSet java/util/Collections$UnmodifiableSet sun/security/util/DisabledAlgorithmConstraints sun/security/util/AbstractAlgorithmConstraints java/security/AlgorithmConstraints sun/security/util/AlgorithmDecomposer java/util/regex/Pattern java/util/regex/Pattern$4 java/util/regex/Pattern$Node java/util/regex/Pattern$LastNode java/util/regex/Pattern$GroupHead java/util/regex/Pattern$Single java/util/regex/Pattern$BmpCharProperty java/util/regex/Pattern$CharProperty java/util/regex/Pattern$Slice java/util/regex/Pattern$SliceNode java/util/regex/Pattern$Begin java/util/regex/Pattern$First java/util/regex/Pattern$Start java/util/regex/Pattern$TreeInfo java/util/regex/ASCII java/util/regex/Pattern$SliceI java/util/regex/Pattern$BranchConn java/util/regex/Pattern$Branch sun/security/util/AbstractAlgorithmConstraints$1 java/security/Security java/security/Security$1 java/util/Properties$LineReader java/util/ArrayList$SubList java/util/ArrayList$SubList$1 java/util/ListIterator sun/security/util/DisabledAlgorithmConstraints$Constraints java/util/regex/Pattern$Ctype java/util/regex/Pattern$Curly java/util/regex/Pattern$GroupTail java/util/regex/Pattern$BnM java/util/regex/Pattern$SliceS java/util/regex/Matcher java/util/regex/MatchResult sun/security/util/DisabledAlgorithmConstraints$KeySizeConstraint sun/security/util/DisabledAlgorithmConstraints$Constraint sun/security/util/DisabledAlgorithmConstraints$Constraint$Operator sun/security/util/DisabledAlgorithmConstraints$1 javassist/ClassPool java/security/PrivilegedActionException javassist/NotFoundException java/lang/reflect/InvocationTargetException javassist/CannotCompileException javassist/CtClass javassist/CtNewClass javassist/CtClassType javassist/CtArray javassist/CtNewNestedClass javassist/ClassPool$1 java/lang/ClassFormatError java/io/IOException java/lang/AssertionStatusDirectives javassist/ClassPoolTail javassist/ClassPath javassist/CtPrimitiveType javassist/ClassMap javassist/CtClass$1 javassist/CtClass$DelayedFileOutputStream javassist/ClassClassPath javassist/ClassPathList javassist/bytecode/AttributeInfo javassist/bytecode/ConstantAttribute javassist/CtMember javassist/CtField javassist/CtConstructor javassist/CtBehavior javassist/CtMethod javassist/bytecode/SignatureAttribute java/io/DataOutputStream java/io/DataOutput javassist/bytecode/InnerClassesAttribute javassist/compiler/CompileError javassist/bytecode/BadBytecode javassist/bytecode/ClassFile javassist/bytecode/DuplicateMemberException java/util/zip/DeflaterInputStream java/lang/invoke/MethodHandles$Lookup java/lang/invoke/MethodHandles sun/invoke/util/Wrapper sun/invoke/util/Wrapper$Format java/lang/Byte$ByteCache java/lang/Short$ShortCache java/lang/Character$CharacterCache java/lang/Long$LongCache java/lang/invoke/MethodType$ConcurrentWeakInternSet java/lang/invoke/MethodTypeForm java/lang/invoke/Invokers java/lang/invoke/MethodType$ConcurrentWeakInternSet$WeakEntry java/lang/NoSuchMethodException sun/invoke/util/VerifyAccess java/lang/invoke/LambdaForm$BasicType java/lang/invoke/LambdaForm$Name java/lang/invoke/LambdaForm$NamedFunction java/lang/invoke/SimpleMethodHandle java/lang/invoke/BoundMethodHandle java/lang/invoke/BoundMethodHandle$SpeciesData java/lang/invoke/BoundMethodHandle$Factory java/lang/invoke/BoundMethodHandle$Species_L sun/invoke/util/BytecodeDescriptor sun/invoke/util/ValueConversions java/lang/invoke/DirectMethodHandle$Lazy java/lang/InstantiationException java/util/Arrays$ArrayList java/util/Collections$UnmodifiableCollection$1 java/util/AbstractList$Itr java/lang/invoke/InvokerBytecodeGenerator jdk/internal/org/objectweb/asm/ClassWriter jdk/internal/org/objectweb/asm/ClassVisitor jdk/internal/org/objectweb/asm/ByteVector jdk/internal/org/objectweb/asm/Item jdk/internal/org/objectweb/asm/MethodWriter jdk/internal/org/objectweb/asm/MethodVisitor jdk/internal/org/objectweb/asm/Type jdk/internal/org/objectweb/asm/Label jdk/internal/org/objectweb/asm/Frame jdk/internal/org/objectweb/asm/AnnotationWriter jdk/internal/org/objectweb/asm/AnnotationVisitor java/lang/invoke/MethodHandleImpl$Intrinsic java/lang/invoke/InvokerBytecodeGenerator$2 sun/invoke/util/VerifyType sun/invoke/empty/Empty java/util/HashMap$Values java/util/HashMap$ValueIterator null null null null null java/lang/NoSuchFieldException java/lang/invoke/InvokerBytecodeGenerator$CpPatch null java/lang/invoke/DirectMethodHandle$Accessor null null null null null null null null null null null java/util/ArrayList$Itr java/util/RandomAccessSubList java/util/SubList java/util/SubList$1 java/util/AbstractList$ListItr null java/lang/invoke/MethodHandleImpl$AsVarargsCollector java/lang/invoke/DelegatingMethodHandle java/lang/invoke/WrongMethodTypeException null null null null java/lang/invoke/MethodHandleImpl$Lazy null java/lang/invoke/MethodHandleImpl$IntrinsicMethodHandle null null null null null null null null null null null null null null null null null null null null null null null null null null null java/lang/NoSuchFieldError java/lang/IllegalAccessException null null null null null java/lang/invoke/LambdaFormEditor java/lang/invoke/LambdaFormEditor$Transform$Kind java/lang/invoke/LambdaFormEditor$Transform java/lang/invoke/LambdaFormBuffer null null null null null null null javassist/bytecode/ConstPool javassist/bytecode/ConstInfo javassist/bytecode/Utf8Info javassist/bytecode/ClassInfo javassist/bytecode/StringInfo javassist/bytecode/FieldrefInfo javassist/bytecode/MemberrefInfo javassist/bytecode/DoubleInfo javassist/bytecode/FloatInfo javassist/bytecode/IntegerInfo javassist/bytecode/LongInfo javassist/bytecode/MethodrefInfo javassist/bytecode/InterfaceMethodrefInfo javassist/bytecode/NameAndTypeInfo javassist/bytecode/MethodHandleInfo javassist/bytecode/MethodTypeInfo javassist/bytecode/InvokeDynamicInfo javassist/bytecode/ConstInfoPadding javassist/bytecode/LongVector javassist/bytecode/Descriptor java/lang/IndexOutOfBoundsException javassist/bytecode/SourceFileAttribute javassist/bytecode/AnnotationDefaultAttribute javassist/bytecode/BootstrapMethodsAttribute javassist/bytecode/CodeAttribute javassist/bytecode/Opcode javassist/bytecode/DeprecatedAttribute javassist/bytecode/EnclosingMethodAttribute javassist/bytecode/ExceptionsAttribute javassist/bytecode/LineNumberAttribute javassist/bytecode/LocalVariableAttribute javassist/bytecode/LocalVariableTypeAttribute javassist/bytecode/MethodParametersAttribute javassist/bytecode/AnnotationsAttribute javassist/bytecode/ParameterAnnotationsAttribute javassist/bytecode/TypeAnnotationsAttribute javassist/bytecode/SyntheticAttribute javassist/bytecode/StackMap javassist/bytecode/StackMapTable javassist/bytecode/AccessFlag javassist/Modifier sun/misc/Launcher$BootClassPathHolder sun/misc/Launcher$BootClassPathHolder$1 javassist/bytecode/FieldInfo javassist/CtMember$Cache java/util/ArrayList$ListItr javassist/CtNewMethod javassist/bytecode/MethodInfo javassist/bytecode/Bytecode javassist/bytecode/ByteVector java/lang/ArrayIndexOutOfBoundsException java/lang/CloneNotSupportedException javassist/bytecode/ExceptionTable java/lang/UnsupportedOperationException javassist/bytecode/CodeAttribute$RuntimeCopyException javassist/compiler/Javac javassist/compiler/ast/Visitor javassist/compiler/JvstCodeGen javassist/compiler/MemberCodeGen javassist/compiler/CodeGen javassist/compiler/TokenId javassist/compiler/ProceedHandler javassist/compiler/Javac$CtFieldWithInit javassist/compiler/ast/ASTList javassist/compiler/ast/ASTree javassist/compiler/ast/Stmnt javassist/compiler/ast/Expr javassist/compiler/ast/AssignExpr javassist/compiler/ast/BinExpr javassist/compiler/ast/CastExpr javassist/compiler/ast/InstanceOfExpr javassist/compiler/CodeGen$ReturnHook javassist/compiler/CodeGen$1 javassist/compiler/TypeChecker javassist/compiler/NoFieldException javassist/compiler/ast/Member javassist/compiler/ast/Symbol javassist/compiler/ast/ArrayInit javassist/compiler/MemberCodeGen$JsrHook2 javassist/compiler/JvstTypeChecker javassist/compiler/MemberResolver javassist/compiler/ast/StringL javassist/compiler/ast/DoubleConst javassist/compiler/ast/IntConst javassist/compiler/ast/Keyword javassist/compiler/ast/CallExpr javassist/compiler/ast/NewExpr javassist/compiler/SymbolTable javassist/compiler/ast/Declarator javassist/compiler/Parser javassist/compiler/SyntaxError javassist/compiler/ast/MethodDecl javassist/compiler/ast/FieldDecl javassist/compiler/ast/Pair javassist/compiler/ast/Variable javassist/compiler/ast/CondExpr javassist/compiler/Lex java/lang/NumberFormatException javassist/compiler/KeywordTable javassist/compiler/Token sun/net/www/protocol/jar/JarURLConnection java/net/JarURLConnection sun/net/www/protocol/jar/JarFileFactory sun/net/www/protocol/jar/URLJarFile$URLJarFileCloseController sun/net/www/protocol/jar/URLJarFile sun/net/www/protocol/jar/URLJarFile$URLJarFileEntry sun/net/www/protocol/jar/JarURLConnection$JarURLInputStream java/io/DataInputStream java/io/DataInput javassist/bytecode/SignatureAttribute$ObjectType javassist/bytecode/SignatureAttribute$Type javassist/bytecode/SignatureAttribute$ArrayType javassist/bytecode/SignatureAttribute$ClassType javassist/bytecode/SignatureAttribute$TypeVariable javassist/bytecode/SignatureAttribute$BaseType javassist/bytecode/StackMapTable$RuntimeCopyException javassist/bytecode/stackmap/MapMaker javassist/bytecode/stackmap/Tracer javassist/bytecode/stackmap/TypeTag javassist/bytecode/stackmap/TypeData javassist/bytecode/stackmap/TypeData$BasicType javassist/bytecode/stackmap/BasicBlock$JsrBytecode javassist/bytecode/stackmap/TypeData$ClassName javassist/bytecode/stackmap/TypedBlock javassist/bytecode/stackmap/BasicBlock java/lang/StringIndexOutOfBoundsException javassist/bytecode/stackmap/TypedBlock$Maker javassist/bytecode/stackmap/BasicBlock$Maker javassist/bytecode/CodeIterator javassist/bytecode/CodeIterator$AlignmentException javassist/bytecode/CodeIterator$Branch javassist/bytecode/CodeIterator$Jump16 javassist/bytecode/CodeIterator$Branch16 javassist/bytecode/CodeIterator$If16 javassist/bytecode/stackmap/BasicBlock$Mark java/util/Arrays$LegacyMergeSort sun/security/action/GetBooleanAction java/util/ComparableTimSort java/io/FileNotFoundException java/net/URLClassLoader$2 javassist/bytecode/ExceptionTableEntry javassist/compiler/MemberResolver$Method javassist/bytecode/ByteArray javassist/bytecode/CodeAttribute$LdcEntry com/vvvtimes/bean/Employee begin! name=gsls200808 age=25 sex=1 end! java/lang/Shutdown java/lang/Shutdown$Lock C:\Users\admin\Desktop>java -javaagent:ClassNameAgent.jar -jar DynamicGenerateClass.jar java/lang/invoke/MethodHandleImpl java/lang/invoke/MethodHandleImpl$1 java/lang/invoke/MethodHandleImpl$2 java/util/function/Function java/lang/invoke/MethodHandleImpl$3 java/lang/invoke/MethodHandleImpl$4 java/lang/ClassValue java/lang/ClassValue$Entry java/lang/ClassValue$Identity java/lang/ClassValue$Version java/lang/invoke/MemberName$Factory java/lang/invoke/MethodHandleStatics java/lang/invoke/MethodHandleStatics$1 sun/misc/PostVMInitHook sun/usagetracker/UsageTrackerClient java/util/concurrent/atomic/AtomicBoolean sun/usagetracker/UsageTrackerClient$1 sun/usagetracker/UsageTrackerClient$4 sun/usagetracker/UsageTrackerClient$2 java/lang/ProcessEnvironment java/lang/ProcessEnvironment$NameComparator java/lang/ProcessEnvironment$EntryComparator java/util/Collections$UnmodifiableMap java/lang/ProcessEnvironment$CheckedEntrySet java/util/HashMap$EntrySet java/lang/ProcessEnvironment$CheckedEntrySet$1 java/util/HashMap$EntryIterator java/util/HashMap$HashIterator java/lang/ProcessEnvironment$CheckedEntry sun/usagetracker/UsageTrackerClient$3 java/io/FileOutputStream$1 sun/launcher/LauncherHelper com/vvvtimes/DynamicGenerateClass sun/launcher/LauncherHelper$FXHelper java/lang/Class$MethodArray java/lang/Void sun/security/util/SignatureFileVerifier java/security/CryptoPrimitive java/util/EnumSet java/lang/Class$4 java/util/RegularEnumSet java/util/Collections$UnmodifiableSet sun/security/util/DisabledAlgorithmConstraints sun/security/util/AbstractAlgorithmConstraints java/security/AlgorithmConstraints sun/security/util/AlgorithmDecomposer java/util/regex/Pattern java/util/regex/Pattern$4 java/util/regex/Pattern$Node java/util/regex/Pattern$LastNode java/util/regex/Pattern$GroupHead java/util/regex/Pattern$Single java/util/regex/Pattern$BmpCharProperty java/util/regex/Pattern$CharProperty java/util/regex/Pattern$Slice java/util/regex/Pattern$SliceNode java/util/regex/Pattern$Begin java/util/regex/Pattern$First java/util/regex/Pattern$Start java/util/regex/Pattern$TreeInfo java/util/regex/ASCII java/util/regex/Pattern$SliceI java/util/regex/Pattern$BranchConn java/util/regex/Pattern$Branch sun/security/util/AbstractAlgorithmConstraints$1 java/security/Security java/security/Security$1 java/util/Properties$LineReader java/util/ArrayList$SubList java/util/ArrayList$SubList$1 java/util/ListIterator sun/security/util/DisabledAlgorithmConstraints$Constraints java/util/regex/Pattern$Ctype java/util/regex/Pattern$Curly java/util/regex/Pattern$GroupTail java/util/regex/Pattern$BnM java/util/regex/Pattern$SliceS java/util/regex/Matcher java/util/regex/MatchResult sun/security/util/DisabledAlgorithmConstraints$KeySizeConstraint sun/security/util/DisabledAlgorithmConstraints$Constraint sun/security/util/DisabledAlgorithmConstraints$Constraint$Operator sun/security/util/DisabledAlgorithmConstraints$1 javassist/ClassPool java/security/PrivilegedActionException javassist/NotFoundException java/lang/reflect/InvocationTargetException javassist/CannotCompileException javassist/CtClass javassist/CtNewClass javassist/CtClassType javassist/CtNewNestedClass javassist/CtArray javassist/ClassPool$1 java/lang/ClassFormatError java/io/IOException java/lang/AssertionStatusDirectives javassist/ClassPoolTail javassist/ClassPath javassist/CtPrimitiveType javassist/ClassMap javassist/CtClass$1 javassist/CtClass$DelayedFileOutputStream javassist/ClassClassPath javassist/ClassPathList javassist/bytecode/AttributeInfo javassist/bytecode/ConstantAttribute javassist/CtMember javassist/CtField javassist/CtConstructor javassist/CtBehavior javassist/CtMethod javassist/bytecode/SignatureAttribute java/io/DataOutputStream java/io/DataOutput javassist/bytecode/InnerClassesAttribute javassist/compiler/CompileError javassist/bytecode/BadBytecode javassist/bytecode/ClassFile javassist/bytecode/DuplicateMemberException java/util/zip/DeflaterInputStream java/lang/invoke/MethodHandles$Lookup java/lang/invoke/MethodHandles sun/invoke/util/Wrapper sun/invoke/util/Wrapper$Format java/lang/Byte$ByteCache java/lang/Short$ShortCache java/lang/Character$CharacterCache java/lang/Long$LongCache java/lang/invoke/MethodType$ConcurrentWeakInternSet java/lang/invoke/MethodTypeForm java/lang/invoke/Invokers java/lang/invoke/MethodType$ConcurrentWeakInternSet$WeakEntry java/lang/NoSuchMethodException sun/invoke/util/VerifyAccess java/lang/invoke/LambdaForm$BasicType java/lang/invoke/LambdaForm$Name java/lang/invoke/LambdaForm$NamedFunction java/lang/invoke/SimpleMethodHandle java/lang/invoke/BoundMethodHandle java/lang/invoke/BoundMethodHandle$SpeciesData java/lang/invoke/BoundMethodHandle$Factory java/lang/invoke/BoundMethodHandle$Species_L sun/invoke/util/BytecodeDescriptor sun/invoke/util/ValueConversions java/lang/invoke/DirectMethodHandle$Lazy java/lang/InstantiationException java/util/Arrays$ArrayList java/util/Collections$UnmodifiableCollection$1 java/util/AbstractList$Itr java/lang/invoke/InvokerBytecodeGenerator jdk/internal/org/objectweb/asm/ClassWriter jdk/internal/org/objectweb/asm/ClassVisitor jdk/internal/org/objectweb/asm/ByteVector jdk/internal/org/objectweb/asm/Item jdk/internal/org/objectweb/asm/MethodWriter jdk/internal/org/objectweb/asm/MethodVisitor jdk/internal/org/objectweb/asm/Type jdk/internal/org/objectweb/asm/Label jdk/internal/org/objectweb/asm/Frame jdk/internal/org/objectweb/asm/AnnotationWriter jdk/internal/org/objectweb/asm/AnnotationVisitor java/lang/invoke/MethodHandleImpl$Intrinsic java/lang/invoke/InvokerBytecodeGenerator$2 sun/invoke/util/VerifyType sun/invoke/empty/Empty java/util/HashMap$Values java/util/HashMap$ValueIterator null null null null null java/lang/NoSuchFieldException java/lang/invoke/InvokerBytecodeGenerator$CpPatch null java/lang/invoke/DirectMethodHandle$Accessor null null null null null null null null null null null java/util/ArrayList$Itr java/util/RandomAccessSubList java/util/SubList java/util/SubList$1 java/util/AbstractList$ListItr null java/lang/invoke/MethodHandleImpl$AsVarargsCollector java/lang/invoke/DelegatingMethodHandle java/lang/invoke/WrongMethodTypeException null null null null java/lang/invoke/MethodHandleImpl$Lazy null java/lang/invoke/MethodHandleImpl$IntrinsicMethodHandle null null null null null null null null null null null null null null null null null null null null null null null null null null null java/lang/NoSuchFieldError java/lang/IllegalAccessException null null null null null java/lang/invoke/LambdaFormEditor java/lang/invoke/LambdaFormEditor$Transform$Kind java/lang/invoke/LambdaFormEditor$Transform java/lang/invoke/LambdaFormBuffer null null null null null null null javassist/bytecode/ConstPool javassist/bytecode/ConstInfo javassist/bytecode/Utf8Info javassist/bytecode/ClassInfo javassist/bytecode/NameAndTypeInfo javassist/bytecode/InterfaceMethodrefInfo javassist/bytecode/MemberrefInfo javassist/bytecode/MethodHandleInfo javassist/bytecode/InvokeDynamicInfo javassist/bytecode/ConstInfoPadding javassist/bytecode/MethodTypeInfo javassist/bytecode/FloatInfo javassist/bytecode/IntegerInfo javassist/bytecode/LongInfo javassist/bytecode/DoubleInfo javassist/bytecode/StringInfo javassist/bytecode/FieldrefInfo javassist/bytecode/MethodrefInfo javassist/bytecode/LongVector javassist/bytecode/Descriptor java/lang/IndexOutOfBoundsException javassist/bytecode/SourceFileAttribute javassist/bytecode/AnnotationDefaultAttribute javassist/bytecode/BootstrapMethodsAttribute javassist/bytecode/CodeAttribute javassist/bytecode/Opcode javassist/bytecode/DeprecatedAttribute javassist/bytecode/EnclosingMethodAttribute javassist/bytecode/ExceptionsAttribute javassist/bytecode/LineNumberAttribute javassist/bytecode/LocalVariableAttribute javassist/bytecode/LocalVariableTypeAttribute javassist/bytecode/MethodParametersAttribute javassist/bytecode/AnnotationsAttribute javassist/bytecode/ParameterAnnotationsAttribute javassist/bytecode/TypeAnnotationsAttribute javassist/bytecode/SyntheticAttribute javassist/bytecode/StackMap javassist/bytecode/StackMapTable javassist/bytecode/AccessFlag javassist/Modifier sun/misc/Launcher$BootClassPathHolder sun/misc/Launcher$BootClassPathHolder$1 javassist/bytecode/FieldInfo javassist/CtMember$Cache java/util/ArrayList$ListItr javassist/CtNewMethod javassist/bytecode/MethodInfo javassist/bytecode/Bytecode javassist/bytecode/ByteVector java/lang/ArrayIndexOutOfBoundsException java/lang/CloneNotSupportedException javassist/bytecode/ExceptionTable java/lang/UnsupportedOperationException javassist/bytecode/CodeAttribute$RuntimeCopyException javassist/compiler/Javac javassist/compiler/ast/Visitor javassist/compiler/JvstCodeGen javassist/compiler/MemberCodeGen javassist/compiler/CodeGen javassist/compiler/TokenId javassist/compiler/ProceedHandler javassist/compiler/Javac$CtFieldWithInit javassist/compiler/TypeChecker javassist/compiler/ast/Expr javassist/compiler/ast/ASTList javassist/compiler/ast/ASTree javassist/compiler/ast/BinExpr javassist/compiler/ast/Stmnt javassist/compiler/CodeGen$ReturnHook javassist/compiler/CodeGen$1 javassist/compiler/ast/AssignExpr javassist/compiler/ast/CastExpr javassist/compiler/ast/InstanceOfExpr javassist/compiler/NoFieldException javassist/compiler/ast/Member javassist/compiler/ast/Symbol javassist/compiler/ast/ArrayInit javassist/compiler/MemberCodeGen$JsrHook2 javassist/compiler/JvstTypeChecker javassist/compiler/MemberResolver javassist/compiler/ast/StringL javassist/compiler/ast/DoubleConst javassist/compiler/ast/IntConst javassist/compiler/ast/Keyword javassist/compiler/ast/NewExpr javassist/compiler/ast/CallExpr javassist/compiler/SymbolTable javassist/compiler/ast/Declarator javassist/compiler/Parser javassist/compiler/SyntaxError javassist/compiler/ast/CondExpr javassist/compiler/ast/Variable javassist/compiler/ast/Pair javassist/compiler/ast/MethodDecl javassist/compiler/ast/FieldDecl javassist/compiler/Lex java/lang/NumberFormatException javassist/compiler/KeywordTable javassist/compiler/Token sun/net/www/protocol/jar/JarURLConnection java/net/JarURLConnection sun/net/www/protocol/jar/JarFileFactory sun/net/www/protocol/jar/URLJarFile$URLJarFileCloseController sun/net/www/protocol/jar/URLJarFile sun/net/www/protocol/jar/URLJarFile$URLJarFileEntry sun/net/www/protocol/jar/JarURLConnection$JarURLInputStream java/io/DataInputStream java/io/DataInput javassist/bytecode/SignatureAttribute$Type javassist/bytecode/SignatureAttribute$ObjectType javassist/bytecode/SignatureAttribute$BaseType javassist/bytecode/SignatureAttribute$ArrayType javassist/bytecode/SignatureAttribute$ClassType javassist/bytecode/SignatureAttribute$TypeVariable javassist/bytecode/StackMapTable$RuntimeCopyException javassist/bytecode/stackmap/MapMaker javassist/bytecode/stackmap/Tracer javassist/bytecode/stackmap/TypeTag javassist/bytecode/stackmap/TypeData javassist/bytecode/stackmap/TypeData$BasicType javassist/bytecode/stackmap/BasicBlock$JsrBytecode javassist/bytecode/stackmap/TypeData$ClassName javassist/bytecode/stackmap/TypedBlock javassist/bytecode/stackmap/BasicBlock java/lang/StringIndexOutOfBoundsException javassist/bytecode/stackmap/TypedBlock$Maker javassist/bytecode/stackmap/BasicBlock$Maker javassist/bytecode/CodeIterator javassist/bytecode/CodeIterator$Branch javassist/bytecode/CodeIterator$Jump16 javassist/bytecode/CodeIterator$Branch16 javassist/bytecode/CodeIterator$If16 javassist/bytecode/CodeIterator$AlignmentException javassist/bytecode/stackmap/BasicBlock$Mark java/util/Arrays$LegacyMergeSort sun/security/action/GetBooleanAction java/util/ComparableTimSort java/io/FileNotFoundException java/net/URLClassLoader$2 javassist/bytecode/ExceptionTableEntry javassist/compiler/MemberResolver$Method javassist/bytecode/ByteArray javassist/bytecode/CodeAttribute$LdcEntry com/vvvtimes/bean/Employee begin! name=gsls200808 age=25 sex=1 end! java/lang/Shutdown java/lang/Shutdown$Lock
可以看到输出的类名都是以斜线/分隔,在最后几行输出了com/vvvtimes/bean/Employee,这个是我们动态生成的类。
下一篇将讨论怎么导出这个类的字节码。
标签:java输出类名
原文地址:http://blog.51cto.com/7317859/2106808