1.0.4 • Published 3 years ago

jaer v1.0.4

Weekly downloads
8
License
MIT
Repository
-
Last release
3 years ago

Jear

  • Some tools for java developer.

Require

node v14.7.0^
jdk: any

install

    npm i jaer -g

Description

Replace class file in jar file

  • jaer help replace
#jaer help replace
-V, --version              output the version number
-s, --source [source]      Source jar file path
-r, --resource [resource]  Resource absoulte path!
-d, --detail               Whether record the detail msg to file
-m, --message [message]    Human readable message for recording the replacement info or others sth..?
-md5, --md5str [md5str]    Get md5 value of specifically file
-h, --help                 display help for command

Jstack tools

  • jaer help jstack
Usage: jaer jstack|jsk [options]

Help get thred stack info to file

Options:
  -p, --pid [pid]         Pid of your java program!
  -i --interval [number]  Interval time 【second】!
  -t --total [number]     Total times for jstack!
  -d --dir [dir]          Log file local storage dir!
  -n --name [name]        Jstack log file prefix!
  -h, --help              display help for command

Example

Replace class file

  • Step1: put the source jar and replace resource in the same folder like this:
.
├── io
│   └── sth
│       └── detail
│           └── service
│               └── AbcService.class
└── test.jar
  • step2: go to *.jar path, with command cd
  • step3: start replacement with jaer.
  • Replace specifically class file
jaer replace -s test.jar -r io/sth/detail/service/AbcService.class
  • Replace multi class file
# the classes file in path io/sth/detail/service will be all replace into jar.
jaer replace -s test.jar -r io/sth/detail/service
  • Record the replace operation info as log file
jaer replace -s test.jar -r io/sth/detail/service -d -m 'This replacement is for fixe error on jira-xxxx'
# then you will get a file the same directory named 'jaer-replace.jaer'
cat jaer-replace.jaer
# file content
================================================================================
DATE: 2021-01-28 14:58:15
SOURCE: test.jar
RESOURCE: io/sth/detail/service
MD5 (Before replacement): 2587bd377a2d2a20c6d8707ff1b6a2ab
MD5 (After replacement): 2587bd377a2d2a20c6d8707ff1b6a2ab
MESSAGE: This replacement is for fixe error on jira-xxxx
================================================================================
DATE: 2021-01-29 14:58:15
SOURCE: test.jar
RESOURCE: io/sth/detail/service
MD5 (Before replacement): 2587bd377a2d2a20c6d8707ff1b6a2ab
MD5 (After replacement): 2587bd377a2d2a20c6d8707ff1b6a2ab
MESSAGE: This replacement is for fixe error on jira-xxxx
================================================================================

Jstack

  • Get the stace trace info of pid with specifically execute plan.
# Using command jps find out your program's pid
jps

# Using jaer to get stack trace.
jaer jstack -p 76204 -i 1 -t 20 -d /Users/myMac/Desktop/jstack-test

### ouput like follow
 ____  _   _ ____  _____ ____        _   _    _____ ____  
 / ___|| | | |  _ \| ____|  _ \      | | / \  | ____|  _ \ 
 \___ \| | | | |_) |  _| | |_) |  _  | |/ _ \ |  _| | |_) |
  ___) | |_| |  __/| |___|  _ <  | |_| / ___ \| |___|  _ < 
 |____/ \___/|_|   |_____|_| \_\  \___/_/   \_\_____|_| \_\
                                                           
INFO: Stack trace info of process[pid:76204]
INFO: ****PLAN: interval-1,total times: 20,may be cost :20 s
Generate to file /Users/my Mac/Desktop/jstack-test/0_jstack_by_jaer_0.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_1.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_2.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_3.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_4.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_5.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_6.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_7.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_8.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_9.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_10.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_11.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_12.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_13.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_14.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_15.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_16.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_17.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_18.log successful!
Generate to file /Users/myMac/Desktop/jstack-test/0_jstack_by_jaer_19.log successful!
==================== 20/20
INFO: All done! Successfuy get stack trace info of process[pid:76204]