English 中文(简体)
构成 Java功能的签名
原标题:Compute a Java function s signature

Is there a way to compute a Java class s method s signature? A signature
like ([Ljava/lang/String;)V represents a function that takes a String[] as argument
and returns void.

What s the rule to compute the signature?

最佳回答

它总是带有一套括号的括号,其中一类是没有mas子或任何东西的,其次是封闭区之后的回报值的表示器。 它非常直截了当。

Here’s a table of type signatures:

Signature    Java Type
Z    boolean
B    byte
C    char
S    short
I    int
J    long
F    float
D    double
V    void
L fully-qualified-class ;    fully-qualified-class
[ type   type[]

Those last two mean that to name a class, you say, for example, Ljava/lang/Object;, and to name an array of (for example) int, you say [I, and an array of array of int is [[I.

如果您想字面上compute signature的签名依据反省,其范围足够简单;只是使用上表,并附有处理物体和阵列的规则。

问题回答

Justpr javap -s <class-name> in the rafter contained the .class file. 它将以100%的准确性告诉你。 无需对这些事情进行猜测。

快速搜索发现这一网页:

http://www.rgagnon.com/javadetails/java-0286.html

There are two parts to the signature. The first part is enclosed within the parentheses and represents the method s arguments. The second portion follows the closing parenthesis and represents the return type. The mapping between the Java type and C type is

Type     Chararacter 
boolean      Z 
byte         B 
char         C 
double       D 
float        F 
int          I 
long         J 
object       L 
short        S 
void         V 
array        [ 

See here for some details.

从根本上说,它会给人带来一些好处,然后是回报。

http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#38649”rel=“nofollow” §8.4.2:

8.4.2 Method Signature

The signature of a method consists of the name of the method and the number and types of formal parameters to the method. A class may not declare two methods with the same signature, or a compile-time error occurs.

The example:

class Point implements Move {
  int x, y;
  abstract void move(int dx, int dy);
  void move(int dx, int dy) { x += dx; y += dy; }
}

causes a compile-time error because it declares two move methods with the same signature. This is an error even though one of the declarations is abstract.

因此,“规则”是

http://www.ohchr.org。

http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#7035“rel=“nofollow” Java 虚拟机器规格





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签