Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Fastjson
Commits
d681ffce
Commit
d681ffce
authored
8 years ago
by
wenshao
Browse files
Options
Download
Email Patches
Plain Diff
1.1.33.internal.v1
parent
27d78b66
Changes
147
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
pom.xml
+1
-1
pom.xml
src/main/java/com/alibaba/fastjson/JSON.java
+5
-1
src/main/java/com/alibaba/fastjson/JSON.java
src/main/java/com/alibaba/fastjson/JSONArray.java
+1
-1
src/main/java/com/alibaba/fastjson/JSONArray.java
src/main/java/com/alibaba/fastjson/JSONAware.java
+1
-1
src/main/java/com/alibaba/fastjson/JSONAware.java
src/main/java/com/alibaba/fastjson/JSONException.java
+1
-1
src/main/java/com/alibaba/fastjson/JSONException.java
src/main/java/com/alibaba/fastjson/JSONObject.java
+1
-1
src/main/java/com/alibaba/fastjson/JSONObject.java
src/main/java/com/alibaba/fastjson/JSONStreamAware.java
+1
-1
src/main/java/com/alibaba/fastjson/JSONStreamAware.java
src/main/java/com/alibaba/fastjson/annotation/JSONField.java
+1
-1
src/main/java/com/alibaba/fastjson/annotation/JSONField.java
src/main/java/com/alibaba/fastjson/annotation/JSONType.java
+1
-1
src/main/java/com/alibaba/fastjson/annotation/JSONType.java
src/main/java/com/alibaba/fastjson/asm/ClassWriter.java
+0
-58
src/main/java/com/alibaba/fastjson/asm/ClassWriter.java
src/main/java/com/alibaba/fastjson/asm/Label.java
+0
-104
src/main/java/com/alibaba/fastjson/asm/Label.java
src/main/java/com/alibaba/fastjson/asm/MethodVisitor.java
+1
-122
src/main/java/com/alibaba/fastjson/asm/MethodVisitor.java
src/main/java/com/alibaba/fastjson/asm/Type.java
+7
-112
src/main/java/com/alibaba/fastjson/asm/Type.java
src/main/java/com/alibaba/fastjson/parser/CharTypes.java
+1
-1
src/main/java/com/alibaba/fastjson/parser/CharTypes.java
src/main/java/com/alibaba/fastjson/parser/DefaultExtJSONParser.java
+1
-1
...ava/com/alibaba/fastjson/parser/DefaultExtJSONParser.java
src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
+2
-2
...n/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
src/main/java/com/alibaba/fastjson/parser/Feature.java
+1
-1
src/main/java/com/alibaba/fastjson/parser/Feature.java
src/main/java/com/alibaba/fastjson/parser/JSONLexer.java
+1
-1
src/main/java/com/alibaba/fastjson/parser/JSONLexer.java
src/main/java/com/alibaba/fastjson/parser/JSONReaderScanner.java
+1
-1
...n/java/com/alibaba/fastjson/parser/JSONReaderScanner.java
src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
+1
-1
src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
with
29 additions
and
413 deletions
+29
-413
pom.xml
+
1
-
1
View file @
d681ffce
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.1.33
</version>
<version>
1.1.33
.internal.v1
</version>
<packaging>
jar
</packaging>
<name>
fastjson
</name>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/JSON.java
+
5
-
1
View file @
d681ffce
...
...
@@ -50,7 +50,7 @@ import com.alibaba.fastjson.util.ThreadLocalCache;
import
com.alibaba.fastjson.util.TypeUtils
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
abstract
class
JSON
implements
JSONStreamAware
,
JSONAware
{
...
...
@@ -658,5 +658,9 @@ public abstract class JSON implements JSONStreamAware, JSONAware {
return
TypeUtils
.
cast
(
json
,
clazz
,
ParserConfig
.
getGlobalInstance
());
}
public
static
<
T
>
T
parseObject
(
String
input
,
Type
clazz
,
ParserConfig
config
,
Feature
...
features
)
{
return
parseObject
(
input
,
clazz
,
config
,
DEFAULT_PARSER_FEATURE
,
features
);
}
public
final
static
String
VERSION
=
"1.1.33"
;
}
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/JSONArray.java
+
1
-
1
View file @
d681ffce
...
...
@@ -43,7 +43,7 @@ import java.util.RandomAccess;
import
com.alibaba.fastjson.util.TypeUtils
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
class
JSONArray
extends
JSON
implements
List
<
Object
>,
JSONAware
,
Cloneable
,
RandomAccess
,
Serializable
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/JSONAware.java
+
1
-
1
View file @
d681ffce
...
...
@@ -18,7 +18,7 @@ package com.alibaba.fastjson;
/**
* Beans that support customized output of JSON text shall implement this interface.
*
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
interface
JSONAware
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/JSONException.java
+
1
-
1
View file @
d681ffce
...
...
@@ -16,7 +16,7 @@
package
com.alibaba.fastjson
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
class
JSONException
extends
RuntimeException
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/JSONObject.java
+
1
-
1
View file @
d681ffce
...
...
@@ -46,7 +46,7 @@ import com.alibaba.fastjson.parser.ParserConfig;
import
com.alibaba.fastjson.util.TypeUtils
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
class
JSONObject
extends
JSON
implements
Map
<
String
,
Object
>,
JSONAware
,
Cloneable
,
Serializable
,
InvocationHandler
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/JSONStreamAware.java
+
1
-
1
View file @
d681ffce
...
...
@@ -20,7 +20,7 @@ import java.io.IOException;
/**
* Beans that support customized output of JSON text to a writer shall implement this interface.
*
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
interface
JSONStreamAware
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/annotation/JSONField.java
+
1
-
1
View file @
d681ffce
...
...
@@ -24,7 +24,7 @@ import com.alibaba.fastjson.parser.Feature;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
METHOD
,
ElementType
.
FIELD
,
ElementType
.
PARAMETER
})
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/annotation/JSONType.java
+
1
-
1
View file @
d681ffce
...
...
@@ -8,7 +8,7 @@ import java.lang.annotation.Target;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
})
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/asm/ClassWriter.java
+
0
-
58
View file @
d681ffce
...
...
@@ -30,32 +30,12 @@
package
com.alibaba.fastjson.asm
;
/**
* A {@link ClassVisitor} that generates classes in bytecode form. More precisely this visitor generates a byte array
* conforming to the Java class file format. It can be used alone, to generate a Java class "from scratch", or with one
* or more and adapter class visitor to generate a modified class from one or more existing Java classes.
*
* @author Eric Bruneton
*/
public
class
ClassWriter
{
/**
* Flag to automatically compute the maximum stack size and the maximum number of local variables of methods. If
* this flag is set, then the arguments of the {@link MethodVisitor#visitMaxs visitMaxs} method of the
* {@link MethodVisitor} returned by the {@link #visitMethod visitMethod} method will be ignored, and computed
* automatically from the signature and the bytecode of each method.
*
* @see #ClassWriter(int)
*/
public
static
final
int
COMPUTE_MAXS
=
1
;
/**
* Flag to automatically compute the stack map frames of methods from scratch. If this flag is set, then the calls
* to the {@link MethodVisitor#visitFrame} method are ignored, and the stack map frames are recomputed from the
* methods bytecode. The arguments of the {@link MethodVisitor#visitMaxs visitMaxs} method are also ignored and
* recomputed from the bytecode. In other words, computeFrames implies computeMaxs.
*
* @see #ClassWriter(int)
*/
public
static
final
int
COMPUTE_FRAMES
=
2
;
/**
...
...
@@ -266,14 +246,6 @@ public class ClassWriter {
*/
final
Item
key3
;
/**
* A type table used to temporarily store internal names that will not necessarily be stored in the constant pool.
* This type table is used by the control flow and data flow analysis algorithm used to compute stack map frames
* from scratch. This array associates to each index <tt>i</tt> the Item whose index is <tt>i</tt>. All Item objects
* stored in this array are also stored in the {@link #items} hash table. These two arrays allow to retrieve an Item
* from its index or, conversely, to get the index of an Item from its value. Each Item stores an internal name in
* its {@link Item#strVal1} field.
*/
Item
[]
typeTable
;
/**
...
...
@@ -526,14 +498,6 @@ public class ClassWriter {
// Utility methods: constant pool management
// ------------------------------------------------------------------------
/**
* Adds a number or string constant to the constant pool of the class being build. Does nothing if the constant pool
* already contains a similar item.
*
* @param cst the value of the constant to be added to the constant pool. This parameter must be an {@link Integer},
* a {@link Float}, a {@link Long}, a {@link Double}, a {@link String} or a {@link Type}.
* @return a new or already existing constant item with the given value.
*/
Item
newConstItem
(
final
Object
cst
)
{
if
(
cst
instanceof
Integer
)
{
int
val
=
((
Integer
)
cst
).
intValue
();
...
...
@@ -605,16 +569,6 @@ public class ClassWriter {
return
result
;
}
/**
* Adds a method reference to the constant pool of the class being build. Does nothing if the constant pool already
* contains a similar item.
*
* @param owner the internal name of the method's owner class.
* @param name the method's name.
* @param desc the method's descriptor.
* @param itf <tt>true</tt> if <tt>owner</tt> is an interface.
* @return a new or already existing method reference item.
*/
Item
newMethodItem
(
final
String
owner
,
final
String
name
,
final
String
desc
,
final
boolean
itf
)
{
int
type
=
itf
?
IMETH
:
METH
;
key3
.
set
(
type
,
owner
,
name
,
desc
);
...
...
@@ -668,13 +622,6 @@ public class ClassWriter {
return
result
;
}
/**
* Returns the constant pool's hash table item which is equal to the given item.
*
* @param key a constant pool item.
* @return the constant pool's hash table item which is equal to the given item, or <tt>null</tt> if there is no
* such item.
*/
private
Item
get
(
final
Item
key
)
{
Item
i
=
items
[
key
.
hashCode
%
items
.
length
];
while
(
i
!=
null
&&
(
i
.
type
!=
key
.
type
||
!
key
.
isEqualTo
(
i
)))
{
...
...
@@ -683,11 +630,6 @@ public class ClassWriter {
return
i
;
}
/**
* Puts the given item in the constant pool's hash table. The hash table <i>must</i> not already contains this item.
*
* @param i the item to be added to the constant pool's hash table.
*/
private
void
put
(
final
Item
i
)
{
if
(
index
>
threshold
)
{
int
ll
=
items
.
length
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/asm/Label.java
+
0
-
104
View file @
d681ffce
...
...
@@ -30,11 +30,6 @@
package
com.alibaba.fastjson.asm
;
/**
* A label represents a position in the bytecode of a method. Labels are used for jump, goto, and switch instructions,
* and for try catch blocks. A label designates the <i>instruction</i> that is just after. Note however that there can
* be other elements between a label and the instruction it designates (such as other labels, stack map frames, line
* numbers, etc.).
*
* @author Eric Bruneton
*/
public
class
Label
{
...
...
@@ -44,11 +39,6 @@ public class Label {
*/
static
final
int
RESOLVED
=
2
;
/**
* Field used to associate user information to a label. Warning: this field is used by the ASM tree package. In
* order to use it with the ASM tree package you must override the
* {@link com.alibaba.fastjson.asm.tree.MethodNode#getLabelNode} method.
*/
public
Object
info
;
int
status
;
...
...
@@ -68,68 +58,14 @@ public class Label {
*/
private
int
referenceCount
;
/**
* Informations about forward references. Each forward reference is described by two consecutive integers in this
* array: the first one is the position of the first byte of the bytecode instruction that contains the forward
* reference, while the second is the position of the first byte of the forward reference itself. In fact the sign
* of the first integer indicates if this reference uses 2 or 4 bytes, and its absolute value gives the position of
* the bytecode instruction. This array is also used as a bitset to store the subroutines to which a basic block
* belongs. This information is needed in {@linked MethodWriter#visitMaxs}, after all forward references have been
* resolved. Hence the same array can be used for both purposes without problems.
*/
private
int
[]
srcAndRefPositions
;
// ------------------------------------------------------------------------
/*
* Fields for the control flow and data flow graph analysis algorithms (used to compute the maximum stack size or
* the stack map frames). A control flow graph contains one node per "basic block", and one edge per "jump" from one
* basic block to another. Each node (i.e., each basic block) is represented by the Label object that corresponds to
* the first instruction of this basic block. Each node also stores the list of its successors in the graph, as a
* linked list of Edge objects. The control flow analysis algorithms used to compute the maximum stack size or the
* stack map frames are similar and use two steps. The first step, during the visit of each instruction, builds
* information about the state of the local variables and the operand stack at the end of each basic block, called
* the "output frame", <i>relatively</i> to the frame state at the beginning of the basic block, which is called the
* "input frame", and which is <i>unknown</i> during this step. The second step, in {@link MethodWriter#visitMaxs},
* is a fix point algorithm that computes information about the input frame of each basic block, from the input
* state of the first basic block (known from the method signature), and by the using the previously computed
* relative output frames. The algorithm used to compute the maximum stack size only computes the relative output
* and absolute input stack heights, while the algorithm used to compute stack map frames computes relative output
* frames and absolute input frames.
*/
/**
* Start of the output stack relatively to the input stack. The exact semantics of this field depends on the
* algorithm that is used. When only the maximum stack size is computed, this field is the number of elements in the
* input stack. When the stack map frames are completely computed, this field is the offset of the first output
* stack element relatively to the top of the input stack. This offset is always negative or null. A null offset
* means that the output stack must be appended to the input stack. A -n offset means that the first n output stack
* elements must replace the top n input stack elements, and that the other elements must be appended to the input
* stack.
*/
int
inputStackTop
;
/**
* Maximum height reached by the output stack, relatively to the top of the input stack. This maximum is always
* positive or null.
*/
int
outputStackMax
;
/**
* The successor of this label, in the order they are visited. This linked list does not include labels used for
* debug info only. If {@link ClassWriter#COMPUTE_FRAMES} option is used then, in addition, it does not contain
* successive labels that denote the same bytecode position (in this case only the first label appears in this
* list).
*/
Label
successor
;
/**
* The next basic block in the basic block stack. This stack is used in the main loop of the fix point algorithm
* used in the second step of the control flow analysis algorithms. It is also used in {@link #visitSubroutine} to
* avoid using a recursive method.
*
* @see MethodWriter#visitMaxs
*/
Label
next
;
// ------------------------------------------------------------------------
...
...
@@ -142,22 +78,6 @@ public class Label {
public
Label
(){
}
// ------------------------------------------------------------------------
// Methods to compute offsets and to manage forward references
// ------------------------------------------------------------------------
/**
* Puts a reference to this label in the bytecode of a method. If the position of the label is known, the offset is
* computed and written directly. Otherwise, a null offset is written and a new forward reference is declared for
* this label.
*
* @param owner the code writer that calls this method.
* @param out the bytecode of the method.
* @param source the position of first byte of the bytecode instruction that contains this label.
* @param wideOffset <tt>true</tt> if the reference must be stored in 4 bytes, or <tt>false</tt> if it must be
* stored with 2 bytes.
* @throws IllegalArgumentException if this label has not been created by the given code writer.
*/
void
put
(
final
MethodWriter
owner
,
final
ByteVector
out
,
final
int
source
)
{
if
((
status
&
RESOLVED
)
==
0
)
{
addReference
(
source
,
out
.
length
);
...
...
@@ -167,15 +87,6 @@ public class Label {
}
}
/**
* Adds a forward reference to this label. This method must be called only for a true forward reference, i.e. only
* if this label is not resolved yet. For backward references, the offset of the reference can be, and must be,
* computed and stored directly.
*
* @param sourcePosition the position of the referencing instruction. This position will be used to compute the
* offset of this forward reference.
* @param referencePosition the position where the offset for this forward reference must be stored.
*/
private
void
addReference
(
final
int
sourcePosition
,
final
int
referencePosition
)
{
if
(
srcAndRefPositions
==
null
)
{
srcAndRefPositions
=
new
int
[
6
];
...
...
@@ -189,21 +100,6 @@ public class Label {
srcAndRefPositions
[
referenceCount
++]
=
referencePosition
;
}
/**
* Resolves all forward references to this label. This method must be called when this label is added to the
* bytecode of the method, i.e. when its position becomes known. This method fills in the blanks that where left in
* the bytecode by each forward reference previously added to this label.
*
* @param owner the code writer that calls this method.
* @param position the position of this label in the bytecode.
* @param data the bytecode of the method.
* @return <tt>true</tt> if a blank that was left for this label was to small to store the offset. In such a case
* the corresponding jump instruction is replaced with a pseudo instruction (using unused opcodes) using an unsigned
* two bytes offset. These pseudo instructions will need to be replaced with true instructions with wider offsets (4
* bytes instead of 2). This is done in {@link MethodWriter#resizeInstructions}.
* @throws IllegalArgumentException if this label has already been resolved, or if it has not been created by the
* given code writer.
*/
void
resolve
(
final
MethodWriter
owner
,
final
int
position
,
final
byte
[]
data
)
{
this
.
status
|=
RESOLVED
;
this
.
position
=
position
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/asm/MethodVisitor.java
+
1
-
122
View file @
d681ffce
...
...
@@ -30,154 +30,33 @@
package
com.alibaba.fastjson.asm
;
/**
* A visitor to visit a Java method. The methods of this interface must be called in the following order: [
* <tt>visitAnnotationDefault</tt> ] ( <tt>visitAnnotation</tt> | <tt>visitParameterAnnotation</tt> |
* <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visitFrame</tt> | <tt>visit</tt><i>X</i>Insn</tt> |
* <tt>visitLabel</tt> | <tt>visitTryCatchBlock</tt> | <tt>visitLocalVariable</tt> | <tt>visitLineNumber</tt>)*
* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In addition, the <tt>visit</tt><i>X</i>Insn</tt> and <tt>visitLabel</tt>
* methods must be called in the sequential order of the bytecode instructions of the visited code,
* <tt>visitTryCatchBlock</tt> must be called <i>before</i> the labels passed as arguments have been visited, and the
* <tt>visitLocalVariable</tt> and <tt>visitLineNumber</tt> methods must be called <i>after</i> the labels passed as
* arguments have been visited.
*
* @author Eric Bruneton
*/
public
interface
MethodVisitor
{
// -------------------------------------------------------------------------
// Annotations and non standard attributes
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Normal instructions
// -------------------------------------------------------------------------
/**
* Visits a zero operand instruction.
*
* @param opcode the opcode of the instruction to be visited. This opcode is either NOP, ACONST_NULL, ICONST_M1,
* ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, FCONST_2,
* DCONST_0, DCONST_1, IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IASTORE, LASTORE, FASTORE,
* DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, IADD,
* LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM,
* INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D,
* L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN,
* FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, or MONITOREXIT.
*/
void
visitInsn
(
int
opcode
);
/**
* Visits an instruction with a single int operand.
*
* @param opcode the opcode of the instruction to be visited. This opcode is either BIPUSH, SIPUSH or NEWARRAY.
* @param operand the operand of the instruction to be visited.<br>
* When opcode is BIPUSH, operand value should be between Byte.MIN_VALUE and Byte.MAX_VALUE.<br>
* When opcode is SIPUSH, operand value should be between Short.MIN_VALUE and Short.MAX_VALUE.<br>
* When opcode is NEWARRAY, operand value should be one of {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},
* {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE}, {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},
* {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.
*/
void
visitIntInsn
(
int
opcode
,
int
operand
);
/**
* Visits a local variable instruction. A local variable instruction is an instruction that loads or stores the
* value of a local variable.
*
* @param opcode the opcode of the local variable instruction to be visited. This opcode is either ILOAD, LLOAD,
* FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
* @param var the operand of the instruction to be visited. This operand is the index of a local variable.
*/
void
visitVarInsn
(
int
opcode
,
int
var
);
/**
* Visits a type instruction. A type instruction is an instruction that takes the internal name of a class as
* parameter.
*
* @param opcode the opcode of the type instruction to be visited. This opcode is either NEW, ANEWARRAY, CHECKCAST
* or INSTANCEOF.
* @param type the operand of the instruction to be visited. This operand must be the internal name of an object or
* array class (see {@link Type#getInternalName() getInternalName}).
*/
void
visitTypeInsn
(
int
opcode
,
String
type
);
/**
* Visits a field instruction. A field instruction is an instruction that loads or stores the value of a field of an
* object.
*
* @param opcode the opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC,
* GETFIELD or PUTFIELD.
* @param owner the internal name of the field's owner class (see {@link Type#getInternalName() getInternalName}).
* @param name the field's name.
* @param desc the field's descriptor (see {@link Type Type}).
*/
void
visitFieldInsn
(
int
opcode
,
String
owner
,
String
name
,
String
desc
);
/**
* Visits a method instruction. A method instruction is an instruction that invokes a method.
*
* @param opcode the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL,
* INVOKESPECIAL, INVOKESTATIC, INVOKEINTERFACE or INVOKEDYNAMIC.
* @param owner the internal name of the method's owner class (see {@link Type#getInternalName() getInternalName})
* or {@link com.alibaba.fastjson.asm.Opcodes#INVOKEDYNAMIC_OWNER}.
* @param name the method's name.
* @param desc the method's descriptor (see {@link Type Type}).
*/
void
visitMethodInsn
(
int
opcode
,
String
owner
,
String
name
,
String
desc
);
/**
* Visits a jump instruction. A jump instruction is an instruction that may jump to another instruction.
*
* @param opcode the opcode of the type instruction to be visited. This opcode is either IFEQ, IFNE, IFLT, IFGE,
* IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR,
* IFNULL or IFNONNULL.
* @param label the operand of the instruction to be visited. This operand is a label that designates the
* instruction to which the jump instruction may jump.
*/
void
visitJumpInsn
(
int
opcode
,
Label
label
);
/**
* Visits a label. A label designates the instruction that will be visited just after it.
*
* @param label a {@link Label Label} object.
*/
void
visitLabel
(
Label
label
);
// -------------------------------------------------------------------------
// Special instructions
// -------------------------------------------------------------------------
/**
* Visits a LDC instruction.
*
* @param cst the constant to be loaded on the stack. This parameter must be a non null {@link Integer}, a
* {@link Float}, a {@link Long}, a {@link Double} a {@link String} (or a {@link Type} for <tt>.class</tt>
* constants, for classes whose version is 49.0 or more).
*/
void
visitLdcInsn
(
Object
cst
);
/**
* Visits an IINC instruction.
*
* @param var index of the local variable to be incremented.
* @param increment amount to increment the local variable by.
*/
void
visitIincInsn
(
int
var
,
int
increment
);
// -------------------------------------------------------------------------
// Exceptions table entries, debug information, max stack and max locals
// -------------------------------------------------------------------------
/**
* Visits the maximum stack size and the maximum number of local variables of the method.
*
* @param maxStack maximum stack size of the method.
* @param maxLocals maximum number of local variables for the method.
*/
void
visitMaxs
(
int
maxStack
,
int
maxLocals
);
/**
* Visits the end of the method. This method, which is the last one to be called, is used to inform the visitor that
* all the annotations and attributes of the method have been visited.
*/
void
visitEnd
();
}
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/asm/Type.java
+
7
-
112
View file @
d681ffce
...
...
@@ -37,104 +37,50 @@ package com.alibaba.fastjson.asm;
*/
public
class
Type
{
/**
* The sort of the <tt>void</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
VOID
=
0
;
/**
* The sort of the <tt>boolean</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
BOOLEAN
=
1
;
/**
* The sort of the <tt>char</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
CHAR
=
2
;
/**
* The sort of the <tt>byte</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
BYTE
=
3
;
/**
* The sort of the <tt>short</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
SHORT
=
4
;
/**
* The sort of the <tt>int</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
INT
=
5
;
/**
* The sort of the <tt>float</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
FLOAT
=
6
;
/**
* The sort of the <tt>long</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
LONG
=
7
;
/**
* The sort of the <tt>double</tt> type. See {@link #getSort getSort}.
*/
public
static
final
int
DOUBLE
=
8
;
/**
* The sort of array reference types. See {@link #getSort getSort}.
*/
public
static
final
int
ARRAY
=
9
;
/**
* The sort of object reference type. See {@link #getSort getSort}.
*/
public
static
final
int
OBJECT
=
10
;
/**
* The <tt>void</tt> type.
*/
public
static
final
Type
VOID_TYPE
=
new
Type
(
VOID
,
null
,
(
'V'
<<
24
)
|
(
5
<<
16
)
|
(
0
<<
8
)
|
0
,
1
);
/**
* The <tt>boolean</tt> type.
*/
public
static
final
Type
BOOLEAN_TYPE
=
new
Type
(
BOOLEAN
,
null
,
(
'Z'
<<
24
)
|
(
0
<<
16
)
|
(
5
<<
8
)
|
1
,
1
);
/**
* The <tt>char</tt> type.
*/
public
static
final
Type
CHAR_TYPE
=
new
Type
(
CHAR
,
null
,
(
'C'
<<
24
)
|
(
0
<<
16
)
|
(
6
<<
8
)
|
1
,
1
);
/**
* The <tt>byte</tt> type.
*/
public
static
final
Type
BYTE_TYPE
=
new
Type
(
BYTE
,
null
,
(
'B'
<<
24
)
|
(
0
<<
16
)
|
(
5
<<
8
)
|
1
,
1
);
/**
* The <tt>short</tt> type.
*/
public
static
final
Type
SHORT_TYPE
=
new
Type
(
SHORT
,
null
,
(
'S'
<<
24
)
|
(
0
<<
16
)
|
(
7
<<
8
)
|
1
,
1
);
/**
* The <tt>int</tt> type.
*/
public
static
final
Type
INT_TYPE
=
new
Type
(
INT
,
null
,
(
'I'
<<
24
)
|
(
0
<<
16
)
|
(
0
<<
8
)
|
1
,
1
);
/**
* The <tt>float</tt> type.
*/
public
static
final
Type
FLOAT_TYPE
=
new
Type
(
FLOAT
,
null
,
(
'F'
<<
24
)
|
(
2
<<
16
)
|
(
2
<<
8
)
|
1
,
1
);
/**
* The <tt>long</tt> type.
*/
public
static
final
Type
LONG_TYPE
=
new
Type
(
LONG
,
null
,
(
'J'
<<
24
)
|
(
1
<<
16
)
|
(
1
<<
8
)
|
2
,
1
);
/**
* The <tt>double</tt> type.
*/
public
static
final
Type
DOUBLE_TYPE
=
new
Type
(
DOUBLE
,
null
,
(
'D'
<<
24
)
|
(
3
<<
16
)
|
(
3
<<
8
)
|
2
,
1
);
// ------------------------------------------------------------------------
...
...
@@ -163,18 +109,6 @@ public class Type {
*/
private
final
int
len
;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
* Constructs a reference type.
*
* @param sort the sort of the reference type to be constructed.
* @param buf a buffer containing the descriptor of the previous type.
* @param off the offset of this descriptor in the previous buffer.
* @param len the length of this descriptor.
*/
private
Type
(
final
int
sort
,
final
char
[]
buf
,
final
int
off
,
final
int
len
){
this
.
sort
=
sort
;
this
.
buf
=
buf
;
...
...
@@ -182,24 +116,11 @@ public class Type {
this
.
len
=
len
;
}
/**
* Returns the Java type corresponding to the given type descriptor.
*
* @param typeDescriptor a type descriptor.
* @return the Java type corresponding to the given type descriptor.
*/
public
static
Type
getType
(
final
String
typeDescriptor
)
{
return
getType
(
typeDescriptor
.
toCharArray
(),
0
);
}
/**
* Computes the size of the arguments and of the return value of a method.
*
* @param desc the descriptor of a method.
* @return the size of the arguments of the method (plus one for the implicit this argument), argSize, and the size
* of its return value, retSize, packed into a single int i = <tt>(argSize << 2) | retSize</tt> (argSize is
* therefore equal to <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
*/
public
static
int
getArgumentsAndReturnSizes
(
final
String
desc
)
{
int
n
=
1
;
int
c
=
1
;
...
...
@@ -277,41 +198,15 @@ public class Type {
}
}
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
/**
* Returns the sort of this Java type.
*
* @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN}, {@link #CHAR CHAR}, {@link #BYTE BYTE}, {@link #SHORT
* SHORT}, {@link #INT INT}, {@link #FLOAT FLOAT}, {@link #LONG LONG}, {@link #DOUBLE DOUBLE}, {@link #ARRAY ARRAY}
* or {@link #OBJECT OBJECT}.
*/
public
int
getSort
()
{
return
sort
;
}
/**
* Returns the internal name of the class corresponding to this object or array type. The internal name of a class
* is its fully qualified name (as returned by Class.getName(), where '.' are replaced by '/'. This method should
* only be used for an object or array type.
*
* @return the internal name of the class corresponding to this object type.
*/
public
String
getInternalName
()
{
return
new
String
(
buf
,
off
,
len
);
}
// ------------------------------------------------------------------------
// Conversion to type descriptors
// ------------------------------------------------------------------------
/**
* Returns the descriptor corresponding to this Java type.
*
* @return the descriptor corresponding to this Java type.
*/
String
getDescriptor
()
{
return
new
String
(
this
.
buf
,
off
,
len
);
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/CharTypes.java
+
1
-
1
View file @
d681ffce
...
...
@@ -16,7 +16,7 @@
package
com.alibaba.fastjson.parser
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
final
class
CharTypes
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/DefaultExtJSONParser.java
+
1
-
1
View file @
d681ffce
...
...
@@ -17,7 +17,7 @@ package com.alibaba.fastjson.parser;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
@Deprecated
public
class
DefaultExtJSONParser
extends
DefaultJSONParser
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
+
2
-
2
View file @
d681ffce
...
...
@@ -68,7 +68,7 @@ import com.alibaba.fastjson.parser.deserializer.StringDeserializer;
import
com.alibaba.fastjson.util.TypeUtils
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
class
DefaultJSONParser
extends
AbstractJSONParser
implements
Closeable
{
...
...
@@ -273,7 +273,7 @@ public class DefaultJSONParser extends AbstractJSONParser implements Closeable {
if
(
key
==
JSON
.
DEFAULT_TYPE_KEY
)
{
String
typeName
=
lexer
.
scanSymbol
(
symbolTable
,
'"'
);
Class
<?>
clazz
=
TypeUtils
.
loadClass
(
typeName
);
Class
<?>
clazz
=
config
.
checkAutoType
(
typeName
,
null
);
if
(
clazz
==
null
)
{
object
.
put
(
JSON
.
DEFAULT_TYPE_KEY
,
typeName
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/Feature.java
+
1
-
1
View file @
d681ffce
...
...
@@ -16,7 +16,7 @@
package
com.alibaba.fastjson.parser
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
enum
Feature
{
/**
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/JSONLexer.java
+
1
-
1
View file @
d681ffce
...
...
@@ -40,7 +40,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONException
;
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
abstract
class
JSONLexer
implements
Closeable
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/JSONReaderScanner.java
+
1
-
1
View file @
d681ffce
...
...
@@ -29,7 +29,7 @@ import com.alibaba.fastjson.util.IOUtils;
//这个类,为了性能优化做了很多特别处理,一切都是为了性能!!!
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
final
class
JSONReaderScanner
extends
JSONLexer
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
+
1
-
1
View file @
d681ffce
...
...
@@ -25,7 +25,7 @@ import com.alibaba.fastjson.util.Base64;
//这个类,为了性能优化做了很多特别处理,一切都是为了性能!!!
/**
* @author wenshao
<
szujobs@hotmail.com
>
* @author wenshao
(
szujobs@hotmail.com
)
*/
public
final
class
JSONScanner
extends
JSONLexer
{
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
…
8
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment