From 59c6ed5d84df1030385d6689b302100f467db7d2 Mon Sep 17 00:00:00 2001 From: amosshi Date: Sun, 1 Sep 2019 08:37:39 +0000 Subject: [PATCH] #4 Add raw data for number values --- .../format/classfile/constant/ConstantDoubleInfo.java | 4 ++++ .../format/classfile/constant/ConstantFloatInfo.java | 3 +++ .../format/classfile/constant/ConstantIntegerInfo.java | 3 +++ .../format/classfile/constant/ConstantLongInfo.java | 3 +++ .../freeinternals/javaclassviewer/ui/JTreeCPInfo.java | 9 +++++---- README.md | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantDoubleInfo.java b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantDoubleInfo.java index 3c73d4e..44ca7ba 100644 --- a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantDoubleInfo.java +++ b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantDoubleInfo.java @@ -32,9 +32,12 @@ */ public class ConstantDoubleInfo extends CPInfo { + public static final int RAW_DATA_SIZE = 8; public static final int LENGTH = 9; + //private u4 high_bytes; //private u4 low_bytes; + public final byte[] rawData; public final double doubleValue; ConstantDoubleInfo(final PosDataInputStream posDataInputStream) throws IOException { @@ -42,6 +45,7 @@ public class ConstantDoubleInfo extends CPInfo { super.startPos = posDataInputStream.getPos() - 1; super.length = LENGTH; + this.rawData = posDataInputStream.getBuf(posDataInputStream.getPos(), RAW_DATA_SIZE); this.doubleValue = posDataInputStream.readDouble(); } diff --git a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantFloatInfo.java b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantFloatInfo.java index 698d2e3..5053edc 100644 --- a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantFloatInfo.java +++ b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantFloatInfo.java @@ -31,7 +31,9 @@ */ public class ConstantFloatInfo extends CPInfo { + public static final int RAW_DATA_SIZE = 4; public static final int LENGTH = 5; + public final byte[] rawData; public final Float floatValue; ConstantFloatInfo(final PosDataInputStream posDataInputStream) throws IOException { @@ -39,6 +41,7 @@ public class ConstantFloatInfo extends CPInfo { super.startPos = posDataInputStream.getPos() - 1; super.length = LENGTH; + this.rawData = posDataInputStream.getBuf(posDataInputStream.getPos(), RAW_DATA_SIZE); this.floatValue = posDataInputStream.readFloat(); } diff --git a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantIntegerInfo.java b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantIntegerInfo.java index f244b56..c534b4a 100644 --- a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantIntegerInfo.java +++ b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantIntegerInfo.java @@ -30,7 +30,9 @@ */ public class ConstantIntegerInfo extends CPInfo { + public static final int RAW_DATA_SIZE = 4; public static final int LENGTH = 5; + public final byte[] rawData; public final int integerValue; ConstantIntegerInfo(final PosDataInputStream posDataInputStream) throws IOException { @@ -38,6 +40,7 @@ public class ConstantIntegerInfo extends CPInfo { super.startPos = posDataInputStream.getPos() - 1; super.length = LENGTH; + this.rawData = posDataInputStream.getBuf(posDataInputStream.getPos(), RAW_DATA_SIZE); this.integerValue = posDataInputStream.readInt(); } diff --git a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantLongInfo.java b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantLongInfo.java index 9125923..dd7275e 100644 --- a/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantLongInfo.java +++ b/FormatCLASS/src/main/java/org/freeinternals/format/classfile/constant/ConstantLongInfo.java @@ -32,10 +32,12 @@ */ public class ConstantLongInfo extends CPInfo { + public static final int RAW_DATA_SIZE = 8; public static final int LENGTH = 9; //private u4 high_bytes; //private u4 low_bytes; + public final byte[] rawData; public final long longValue; ConstantLongInfo(final PosDataInputStream posDataInputStream) throws IOException { @@ -43,6 +45,7 @@ public class ConstantLongInfo extends CPInfo { super.startPos = posDataInputStream.getPos() - 1; super.length = LENGTH; + this.rawData = posDataInputStream.getBuf(posDataInputStream.getPos(), RAW_DATA_SIZE); this.longValue = posDataInputStream.readLong(); } diff --git a/JavaClassViewer/src/main/java/org/freeinternals/javaclassviewer/ui/JTreeCPInfo.java b/JavaClassViewer/src/main/java/org/freeinternals/javaclassviewer/ui/JTreeCPInfo.java index 7733751..ee6c79a 100644 --- a/JavaClassViewer/src/main/java/org/freeinternals/javaclassviewer/ui/JTreeCPInfo.java +++ b/JavaClassViewer/src/main/java/org/freeinternals/javaclassviewer/ui/JTreeCPInfo.java @@ -7,6 +7,7 @@ package org.freeinternals.javaclassviewer.ui; import javax.swing.tree.DefaultMutableTreeNode; +import org.freeinternals.commonlib.core.BytesTool; import org.freeinternals.commonlib.ui.JTreeNodeFileComponent; import org.freeinternals.format.classfile.constant.CPInfo; import org.freeinternals.format.classfile.ClassFile; @@ -112,7 +113,7 @@ private void generateTreeNode(final DefaultMutableTreeNode rootNode, final Const rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( integerInfo.getStartPos() + 1, 4, - "bytes: " + integerInfo.integerValue + "bytes: " + integerInfo.integerValue + " - " + BytesTool.getByteDataHexView(integerInfo.rawData) ))); } @@ -120,7 +121,7 @@ private void generateTreeNode(final DefaultMutableTreeNode rootNode, final Const rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( floatInfo.getStartPos() + 1, 4, - "bytes: " + floatInfo.floatValue + "bytes: " + floatInfo.floatValue + " - " + BytesTool.getByteDataHexView(floatInfo.rawData) ))); } @@ -130,7 +131,7 @@ private void generateTreeNode(final DefaultMutableTreeNode rootNode, final Const rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos + 1, 4, - "high_bytes - value: " + longInfo.longValue + "high_bytes - value: " + longInfo.longValue + " - " + BytesTool.getByteDataHexView(longInfo.rawData) ))); rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos + 5, @@ -145,7 +146,7 @@ private void generateTreeNode(final DefaultMutableTreeNode rootNode, final Const rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos + 1, 4, - "high_bytes - value: " + doubleInfo.doubleValue + "high_bytes - value: " + doubleInfo.doubleValue + " - " + BytesTool.getByteDataHexView(doubleInfo.rawData) ))); rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos + 5, diff --git a/README.md b/README.md index bf252db..c1c0c0c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Supported Formats Build the Source Code ========================= -We request the maven command line `mvn` has been instaled. +We require the maven command line `mvn` has been installed. - `./build.sh` Build the source code and create the deploy packages