什么是“()V”在班级签名中意味着什么? [英] What does "()V" mean in a class signature?
本文介绍了什么是“()V”在班级签名中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用Javassist创建了一个没有实际方法的构造函数
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();
我得到
public Echo ()V
我很困惑V是什么意思?我期待公共Echo();或类似的东西...
I'm confused what "V" means? I expected either public Echo (); or something similar...
推荐答案
JVM使用一种紧凑的方式来存储方法签名,其中构造函数被认为是一种特殊情况。
The JVM uses a compact way of storing method signatures, of which constructors are considered a special case.
对于你的例子:
-
()
表示不带参数的方法 -
V
表示它不返回任何内容
()
indicates a method taking no argumentsV
indicates that it returns nothing
该计划的其他部分是:
-
B
- 字节 -
C
- char -
D
- double -
F
- float -
我
- int -
J
- long -
S
- 短 -
V
- void -
Z
- boolean -
[
- 括号后面的数组 -
L
[类名];
- 此类的实例,点变为斜杠 -
(
[args])
[返回类型] - 方法签名
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
例如:
public int foo(String bar, long[][] baz)
将成为
(Ljava/lang/String;[[J)I
参见规范
这篇关于什么是“()V”在班级签名中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文