FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java/src/main/java/com/jsoniter/DynamicCodegen.java at master · baowchen/java · GitHub
baowchen
/
java
Public
forked from
json-iterator/java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
DynamicCodegen.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (28 loc) · 1.15 KB
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
DynamicCodegen.java
Copy path
File metadata and controls
34 lines (28 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package
com
.
jsoniter
;
import
com
.
jsoniter
.
spi
.
Decoder
;
import
javassist
.*;
class
DynamicCodegen
{
static
ClassPool
pool
=
ClassPool
.
getDefault
();
static
{
pool
.
insertClassPath
(
new
ClassClassPath
(
Decoder
.
class
));
}
public
static
Decoder
gen
(
String
cacheKey
,
String
source
)
throws
Exception
{
Decoder
decoder
;
CtClass
ctClass
=
pool
.
makeClass
(
cacheKey
);
ctClass
.
setInterfaces
(
new
CtClass
[]{
pool
.
get
(
Decoder
.
class
.
getName
())});
CtMethod
staticMethod
=
CtNewMethod
.
make
(
source
,
ctClass
);
ctClass
.
addMethod
(
staticMethod
);
CtMethod
interfaceMethod
=
CtNewMethod
.
make
(
""
+
"public Object decode(com.jsoniter.JsonIterator iter) {"
+
"return decode_(iter);"
+
"}"
,
ctClass
);
ctClass
.
addMethod
(
interfaceMethod
);
decoder
= (
Decoder
)
ctClass
.
toClass
().
newInstance
();
return
decoder
;
}
public
static
void
enableStreamingSupport
()
throws
Exception
{
CtClass
ctClass
=
pool
.
makeClass
(
"com.jsoniter.IterImpl"
);
ctClass
.
setSuperclass
(
pool
.
get
(
IterImplForStreaming
.
class
.
getName
()));
ctClass
.
toClass
();
}
}
Back
|
FazBrowse Home
|
New Git URL