问题
I created a constructor with Javassist which has no real method
CtConstructor c = CtNewConstructor.make ( argTypes, null, newClass );
When I'm trying to put out the signature of this class
c.getSignature();
I get
public Echo ()V
I'm confused what "V" means? I expected either public Echo (); or something similar...
回答1:
The JVM uses a compact way of storing method signatures, of which constructors are considered a special case.
For your example:
()
indicates a method taking no argumentsV
indicates that it returns nothing
The other parts of the scheme are:
B
- byteC
- charD
- doubleF
- floatI
- intJ
- longS
- shortV
- voidZ
- boolean[
- array of the thing following the bracketL
[class name];
- instance of this class, with dots becoming slashes(
[args])
[return type] - method signature
For example:
public int foo(String bar, long[][] baz)
would become
(Ljava/lang/String;[[J)I
See the spec at Sun^H^H^HOracle's web site
回答2:
"V" determines the result type "void"
回答3:
V in a type signature means void type. Bytecode does not differentiate constructors from other methods (other than using special method name).
来源:https://stackoverflow.com/questions/9909228/what-does-v-mean-in-a-class-signature