今天尝试的去反编译一下匿名类,结果发现反编译不成功,那么匿名类该怎么样反编译啊?
反编译工具:jd-gui
反编译结果:
XmlConverter.class :
反编译工具:jd-gui
反编译结果:
XmlConverter.class :
package com.alipay.api.internal.parser.xml; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayResponse; import com.alipay.api.internal.mapping.Converter; import com.alipay.api.internal.mapping.Converters; import com.alipay.api.internal.mapping.Reader; import com.alipay.api.internal.util.XmlUtils; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.w3c.dom.Element; public class XmlConverter implements Converter { public <T extends AlipayResponse> T toResponse(String rsp, Class<T> clazz) throws AlipayApiException { Element root = XmlUtils.getRootElementFromString(rsp); return (AlipayResponse)getModelFromXML(root, clazz); } private <T> T getModelFromXML(final Element element, Class<T> clazz) throws AlipayApiException { if (element == null) { return null; } Converters.convert(clazz, new Reader() { public boolean hasReturnField(Object name) { Element childE = XmlUtils.getChildElement(element, (String)name); return childE != null; } public Object getPrimitiveObject(Object name) { return XmlUtils.getElementValue(element, (String)name); } public Object getObject(Object name, Class<?> type) throws AlipayApiException { Element childE = XmlUtils.getChildElement(element, (String)name); if (childE != null) { return XmlConverter.this.getModelFromXML(childE, type); } return null; } public List<?> getListObjects(Object listName, Object itemName, Class<?> subType) throws AlipayApiException { List<Object> list = null; Element listE = XmlUtils.getChildElement(element, (String)listName); if (listE != null) { list = new ArrayList(); List<Element> itemEs = XmlUtils.getChildElements(listE, (String)itemName); for (Element itemE : itemEs) { Object obj = null; String value = XmlUtils.getElementValue(itemE); if (String.class.isAssignableFrom(subType)) { obj = value; } else if (Long.class.isAssignableFrom(subType)) { obj = Long.valueOf(value); } else if (Integer.class.isAssignableFrom(subType)) { obj = Integer.valueOf(value); } else if (Boolean.class.isAssignableFrom(subType)) { obj = Boolean.valueOf(value); } else if (Date.class.isAssignableFrom(subType)) { DateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); try { obj = format.parse(value); } catch (ParseException e) { throw new AlipayApiException(e); } } else { obj = XmlConverter.this.getModelFromXML(itemE, subType); } if (obj != null) { list.add(obj); } } } return list; } }); } }
XmlConverter$1.class:
package com.alipay.api.internal.parser.xml; import com.alipay.api.AlipayApiException; import com.alipay.api.internal.mapping.Reader; import com.alipay.api.internal.util.XmlUtils; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.w3c.dom.Element; final class XmlConverter$1 implements Reader { XmlConverter$1(XmlConverter paramXmlConverter, Element paramElement) {} public boolean hasReturnField(Object name) { Element childE = XmlUtils.getChildElement(this.val$element, (String)name); return childE != null; } public Object getPrimitiveObject(Object name) { return XmlUtils.getElementValue(this.val$element, (String)name); } public Object getObject(Object name, Class<?> type) throws AlipayApiException { Element childE = XmlUtils.getChildElement(this.val$element, (String)name); if (childE != null) { return XmlConverter.access$0(this.this$0, childE, type); } return null; } public List<?> getListObjects(Object listName, Object itemName, Class<?> subType) throws AlipayApiException { List<Object> list = null; Element listE = XmlUtils.getChildElement(this.val$element, (String)listName); if (listE != null) { list = new ArrayList(); List<Element> itemEs = XmlUtils.getChildElements(listE, (String)itemName); for (Element itemE : itemEs) { Object obj = null; String value = XmlUtils.getElementValue(itemE); if (String.class.isAssignableFrom(subType)) { obj = value; } else if (Long.class.isAssignableFrom(subType)) { obj = Long.valueOf(value); } else if (Integer.class.isAssignableFrom(subType)) { obj = Integer.valueOf(value); } else if (Boolean.class.isAssignableFrom(subType)) { obj = Boolean.valueOf(value); } else if (Date.class.isAssignableFrom(subType)) { DateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); try { obj = format.parse(value); } catch (ParseException e) { throw new AlipayApiException(e); } } else { obj = XmlConverter.access$0(this.this$0, itemE, subType); } if (obj != null) { list.add(obj); } } } return list; } }
反编译出来的结果都会报错,看的一头雾水啊,没有$的那个class反编译出来后,缺少return;而$1.class反编译生成的java类中对象都成了object,还有方法,变量都带有$。
解决方案
3
呵呵,反编译就是这样子了,会丢失一些信息的,不能完全的得到源码。不过基本也差不多了,本人补全丢失的信息吧。
14
3
JD 工具还瞒好用的,