本文介绍:jad,sc的使用

5.jad反编译

可以使用jad反编译class文件,中文字符会被编解码。
这里以com.runlion.fsp.credit.service.impl包下为例NCSourceServiceImpl类为例:
我们可以看到整个类的ClassLoader,从哪里加载的,以及类的完整信息;

$ jad com.runlion.fsp.credit.service.impl.NCSourceServiceImpl
$ jad com.runlion.fsp.credit.service.impl.NCSourceServiceImpl

ClassLoader:
+-org.springframework.boot.loader.LaunchedURLClassLoader@681a9515
+-sun.misc.Launcher$AppClassLoader@70dea4e
+-sun.misc.Launcher$ExtClassLoader@30f39991

Location:
file:/home/fsp/servers/credit-web-1.0-RELEASE.jar!/BOOT-INF/classes!/

/*
* Decompiled with CFR 0_132.
*
* Could not load the following classes:
* com.alibaba.fastjson.JSON
省略。。。。。。
* org.springframework.stereotype.Service
*/
package com.runlion.fsp.credit.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
省略。。。。。。
import org.springframework.stereotype.Service;

@Service(value="nCSourceServiceImpl")
public class NCSourceServiceImpl
implements NCSourceService {
private static final Logger log = LoggerFactory.getLogger(NCSourceServiceImpl.class);
@Value(value="${nc.credit.queryYearDiscount.address}")
private String queryYearDiscountAddress;
@Value(value="${nc.credit.queryYearDiscount.method}")
private String queryYearDiscountMethod;
@Value(value="${nc.credit.querySupplierCorpCredit.address}")
private String querySupplierCorpCredit;
@Value(value="${nc.credit.querySupplierAllCorpCredit.address}")
private String querySupplierAllCorpCredit;

public BigDecimal getDealNoBackMnyFromNC(String custcode, String companycode) {
log.info("\u3010\u6388\u4fe1\u8c03\u7528NC\u67e5\u8be2\u7d2f\u8ba1\u672a\u9000\u91d1\u989d\u3011\u4eceNC\u83b7\u53d6\u7ecf\u9500\u5546\u7d2f\u8ba1\u672a\u9000\u91d1\u989d,\u5165\u53c2\u4e3acustcode=" + custcode + ",companycode=" + companycode + ",\u5730\u5740\u4e3a\uff1a" + this.queryYearDiscountAddress);
OMElement omElement = null;
BigDecimal noBackMny = BigDecimal.ZERO;
try {
ServiceClient serviceClient = new ServiceClient();
String url = this.queryYearDiscountAddress;
EndpointReference targetEPR = new EndpointReference(url);
省略。。。。。。

6.sc 查看

使用sc命令查看一个类的加载情况

$ sc com.runlion.fsp.credit.controller.web.CreditController
com.runlion.fsp.credit.controller.web.CreditController
Affect(row-cnt:1) cost in 10 ms.
$

输出当前类的详细信息,包括这个类所加载的原始文件来源、类的声明、加载的ClassLoader等详细信息。

$ sc -d com.runlion.fsp.credit.controller.web.CreditController
class-info com.runlion.fsp.credit.controller.web.CreditController
code-source file:/home/fsp/servers/credit-web-1.0-RELEASE.jar!/BOOT-INF/classes!/
name com.runlion.fsp.credit.controller.web.CreditController
isInterface false
isAnnotation false
isEnum false
isAnonymousClass false
isArray false
isLocalClass false
isMemberClass false
isPrimitive false
isSynthetic false
simple-name CreditController
modifier public
annotation org.springframework.web.bind.annotation.RestController,org.springframework.web.bind.annotation.RequestMapping
interfaces
super-class +-java.lang.Object
class-loader +-org.springframework.boot.loader.LaunchedURLClassLoader@681a9515
+-sun.misc.Launcher$AppClassLoader@70dea4e
+-sun.misc.Launcher$ExtClassLoader@30f39991
classLoaderHash 681a9515

Affect(row-cnt:1) cost in 13 ms.