Java method signature and field type representation-[ljava.lang.string;__java

Source: Internet
Author: User

When do we have access to the Java method signature? When a JNI call is made, there is also a way to look at the method overload. Overloaded methods have different method signatures, but do not distinguish between return values, and the actual method signature is also rubbed into the return value type, and is javap-s to view the method signature, such as Javap-s java.util.Date.

It seems that the method signature does not really relate to our actual work. It's been a while, but it's a problem. Submitting a form in STRUTS2 application The times out the following error:

00:43:59.716 [http-8080-4] WARN com.opensymphony.xwork2.ognl.ognlvaluestack-error setting expression ' version ' with VA Lue ' [Ljava.lang.String; @e18a9a '
Ognl. Methodfailedexception:method "Setversion" failed for object Cc.unmi.model.post@ed0cd7
At OGNL. Ognlruntime.callappropriatemethod (ognlruntime.java:1285) ~[ognl-3.0.jar:na]
At OGNL. Ognlruntime.setmethodvalue (ognlruntime.java:1474) ~[ognl-3.0.jar:na]
At OGNL. Objectpropertyaccessor.setpossibleproperty (objectpropertyaccessor.java:85) ~[ognl-3.0.jar:na]
At OGNL. Objectpropertyaccessor.setproperty (objectpropertyaccessor.java:162) ~[ognl-3.0.jar:na]
At Com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty (objectaccessor.java:27) ~[ xwork-core-2.2.1.jar:2.2.1]
At OGNL. Ognlruntime.setproperty (ognlruntime.java:2245) ~[ognl-3.0.jar:na]
At Com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty (compoundrootaccessor.java:77) ~[ xwork-core-2.2.1.jar:2.2.1]
At OGNL. Ognlruntime.setproperty (ognlruntime.java:2245) ~[ognl-3.0.jar:na]
At OGNL. Astproperty.setvaluebody (astproperty.java:127) ~[ognl-3.0.jar:na]
At OGNL. Simplenode.evaluatesetvaluebody (simplenode.java:220) ~[ognl-3.0.jar:na]
At OGNL. Simplenode.setvalue (simplenode.java:301) ~[ognl-3.0.jar:na]
At OGNL. Ognl.setvalue (ognl.java:737) ~[ognl-3.0.jar:na]
At Com.opensymphony.xwork2.ognl.OgnlUtil.setValue (ognlutil.java:209) ~[xwork-core-2.2.1.jar:2.2.1]
At Com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue (ognlvaluestack.java:173) [xwork-core-2.2.1.jar:2.2.1]

...........................................................

At Org.apache.coyote.http11.http11protocol$http11connectionhandler.process (http11protocol.java:583) [ Tomcat-coyote.jar:na]
At Org.apache.tomcat.util.net.jioendpoint$worker.run (jioendpoint.java:454) [Tomcat-coyote.jar:na]
At Java.lang.Thread.run (thread.java:619) [na:1.6.0_20]
caused by:java.lang.NoSuchMethodException:cc.unmi.model.Post.setVersion ([Ljava.lang.String;)
At OGNL. Ognlruntime.callappropriatemethod (ognlruntime.java:1226) ~[ognl-3.0.jar:na]
... Common frames omitted

The lack of setversion () method, look at the Post.java does have ah. Note that the parameter is [Ljava.lang.String; it is difficult to understand that there is no setversion (string[] args) method if you do not understand [L's intention]. Lxxx; Used to represent an object type, used to represent an array.

The reason for this is that there are two version parameters in the request, perhaps two in the form, one in the URL, one in the form, or an array with Request.getparametervalue ("version"). In fact, for httpservletrequest, whether the submission is a version or multiple version values, with Request.getparameter ("version") always take the first submitted version value, so this in St Ruts1 does not seem to make a similar mistake. One or more version effects always getparametervalue ("version") is null.

The solution is to leave only a version request parameter, which warns us that there is a certain sense of smell in the data type notation in the JVM.

The following is a list of Java types and representations in virtual machines:

Prefix for byte code mnemonics

Type Code Example Describe
Byte B Baload Load byte type from array
Short S Sastore Storing the short type in an array
Int I Iload_1 load int type from local variable 1
Long L lcmp Compare long type values
Char C I2c convert int type data to char type
Float F Fload Load float type from local variable
Double D Dconst_1 Press the double type constant 1.0 into the stack
Reference A Aaload To load a reference type from an array
The original chain of this article

Save types and calculation types in Java virtual machines

Save Type Minimum number of bits in a heap or method area Calculation type Word length in Java stack frames
Byte 8 Int 1
Short 16 Int 1
Int 32 Int 1
Long 64 Long 2
Char 16 Int 1
Float 32 Float 1
Double 64 Double 2
Reference 32 Reference 1

Basic Type Non-terminal (this is closer to the method signature)

Non-terminal Type
B Byte
C Char
D Double
F Float
I Int
J Long
S Short
Z Boolean

The Boolean non-terminal is not B is used to let byte occupy, long non-terminal is not L also because the object non-terminal occupies. Non-terminal with the return value of void type are V, object type non-terminal to L and;, array type non-terminal [

Field Description Descriptor Example

Descriptor Field declaration
I int I
[[J Long[][] Windingroad
[Ljava/lang/object; Object[] Stuff
Ljava/util. Hashtable; Java.util.Hashtable HT
[[[Z Boolean[][][] IsReady

Methods to describe Descriptor cases

void Wait () ,
Descriptor method declaration
() I int getsize ()
() ljava/lang/string; String toString ()
([ljava/lang/string;) v void Main (string[] args)
() V
(JI) V void Wait (long timeout, int nanos)
(z[ljava/lang/string;ii) Z Boolean regionmatches (boolean ignoreCase, int tooffset, String other, in Oooffset, int len
([BII) I

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.