dspinellis / ckjm

Chidamber and Kemerer Java Metrics
http://www.spinellis.gr/sw/ckjm/
Apache License 2.0
96 stars 47 forks source link

Error obtaining all superclasses of public class #4

Open efferifick opened 5 years ago

efferifick commented 5 years ago

Hi,

I have done the following:

And I receive the following output:

$ find jar/ -name '*.class' -print | java -jar ckjm-1.9/build/ckjm-1.9.jar
Error obtaining all superclasses of public class org.sunflow.core.tesselatable.Teapot extends org.sunflow.core.tesselatable.BezierMesh
filename        jar/org/sunflow/core/tesselatable/Teapot.class
compiled from       Teapot.java
compiler version    52.0
access flags        33
constant pool       119 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(Teapot.java)

1 fields:
    private static final float[][] PATCHES

2 methods:
    public void <init>()
    static void <clinit>()

Error obtaining all superclasses of public class org.sunflow.core.tesselatable.Gumbo extends org.sunflow.core.tesselatable.BezierMesh
filename        jar/org/sunflow/core/tesselatable/Gumbo.class
compiled from       Gumbo.java
compiler version    52.0
access flags        33
constant pool       2028 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(Gumbo.java)
    InnerClass:public static org.sunflow.system.Parser$ParserException("org.sunflow.system.Parser", "ParserException")

1 fields:
    private static final float[][] PATCHES

4 methods:
    public static void main(String[] args)
    private static float[] parseFloatArray(org.sunflow.system.Parser p)
        throws java.io.IOException
    public void <init>()
    static void <clinit>()

Error obtaining all superclasses of public final class org.sunflow.core.Options extends org.sunflow.core.ParameterList
implements      org.sunflow.core.RenderObject
filename        jar/org/sunflow/core/Options.class
compiled from       Options.java
compiler version    52.0
access flags        49
constant pool       71 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(Options.java)
    InnerClass:public static org.sunflow.util.FastHashMap$Entry("org.sunflow.util.FastHashMap", "Entry")
    InnerClass:protected static final org.sunflow.core.ParameterList$Parameter("org.sunflow.core.ParameterList", "Parameter")

2 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)

Error obtaining all superclasses of public class org.sunflow.core.shader.TexturedWardShader extends org.sunflow.core.shader.AnisotropicWardShader
filename        jar/org/sunflow/core/shader/TexturedWardShader.class
compiled from       TexturedWardShader.java
compiler version    52.0
access flags        33
constant pool       78 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(TexturedWardShader.java)

1 fields:
    private org.sunflow.core.Texture tex

3 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)
    public org.sunflow.image.Color getDiffuse(org.sunflow.core.ShadingState state)

Error obtaining all superclasses of public class org.sunflow.core.shader.TexturedShinyDiffuseShader extends org.sunflow.core.shader.ShinyDiffuseShader
filename        jar/org/sunflow/core/shader/TexturedShinyDiffuseShader.class
compiled from       TexturedShinyDiffuseShader.java
compiler version    52.0
access flags        33
constant pool       78 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(TexturedShinyDiffuseShader.java)

1 fields:
    private org.sunflow.core.Texture tex

3 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)
    public org.sunflow.image.Color getDiffuse(org.sunflow.core.ShadingState state)

Error obtaining all superclasses of public class org.sunflow.core.shader.TexturedAmbientOcclusionShader extends org.sunflow.core.shader.AmbientOcclusionShader
filename        jar/org/sunflow/core/shader/TexturedAmbientOcclusionShader.class
compiled from       TexturedAmbientOcclusionShader.java
compiler version    52.0
access flags        33
constant pool       78 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(TexturedAmbientOcclusionShader.java)

1 fields:
    private org.sunflow.core.Texture tex

3 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)
    public org.sunflow.image.Color getBrightColor(org.sunflow.core.ShadingState state)

Error obtaining all superclasses of public class org.sunflow.core.shader.TexturedDiffuseShader extends org.sunflow.core.shader.DiffuseShader
filename        jar/org/sunflow/core/shader/TexturedDiffuseShader.class
compiled from       TexturedDiffuseShader.java
compiler version    52.0
access flags        33
constant pool       78 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(TexturedDiffuseShader.java)

1 fields:
    private org.sunflow.core.Texture tex

3 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)
    public org.sunflow.image.Color getDiffuse(org.sunflow.core.ShadingState state)

Error obtaining all superclasses of public class org.sunflow.core.shader.TexturedPhongShader extends org.sunflow.core.shader.PhongShader
filename        jar/org/sunflow/core/shader/TexturedPhongShader.class
compiled from       TexturedPhongShader.java
compiler version    52.0
access flags        33
constant pool       78 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(TexturedPhongShader.java)

1 fields:
    private org.sunflow.core.Texture tex

3 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)
    public org.sunflow.image.Color getDiffuse(org.sunflow.core.ShadingState state)

Error obtaining all superclasses of public class org.sunflow.core.light.TriangleMeshLight extends org.sunflow.core.primitive.TriangleMesh
implements      org.sunflow.core.Shader
filename        jar/org/sunflow/core/light/TriangleMeshLight.class
compiled from       TriangleMeshLight.java
compiler version    52.0
access flags        33
constant pool       209 entries
ACC_SUPER flag      true

Attribute(s):
    SourceFile(TriangleMeshLight.java)
    InnerClass:private org.sunflow.core.light.TriangleMeshLight$TriangleLight("org.sunflow.core.light.TriangleMeshLight", "TriangleLight")

2 fields:
    private org.sunflow.image.Color radiance
    private int numSamples

49 methods:
    public void <init>()
    public boolean update(org.sunflow.core.ParameterList pl, org.sunflow.SunflowAPI api)
    public void init(String name, org.sunflow.SunflowAPI api)
    public org.sunflow.image.Color getRadiance(org.sunflow.core.ShadingState state)
    public void scatterPhoton(org.sunflow.core.ShadingState state, org.sunflow.image.Color power)
    static synthetic int[] access$000(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$100(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$200(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic org.sunflow.math.Point3 access$300(org.sunflow.core.light.TriangleMeshLight x0, int x1)
    static synthetic org.sunflow.math.Point3 access$400(org.sunflow.core.light.TriangleMeshLight x0, int x1)
    static synthetic org.sunflow.math.Point3 access$500(org.sunflow.core.light.TriangleMeshLight x0, int x1)
    static synthetic int access$600(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$700(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$800(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$900(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1000(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1100(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1200(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1300(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1400(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1500(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1600(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1700(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1800(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$1900(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$2000(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$2100(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$2200(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$2300(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$2400(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$2500(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic org.sunflow.math.Point3 access$2600(org.sunflow.core.light.TriangleMeshLight x0, int x1)
    static synthetic int[] access$2700(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic org.sunflow.math.Point3 access$2800(org.sunflow.core.light.TriangleMeshLight x0, int x1)
    static synthetic int[] access$2900(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic org.sunflow.math.Point3 access$3000(org.sunflow.core.light.TriangleMeshLight x0, int x1)
    static synthetic org.sunflow.image.Color access$3100(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$3200(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$3300(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic int[] access$3400(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$3500(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$3600(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$3700(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$3800(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$3900(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$4000(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$4100(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$4200(org.sunflow.core.light.TriangleMeshLight x0)
    static synthetic float[] access$4300(org.sunflow.core.light.TriangleMeshLight x0)

Error reading line: org.apache.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18

For Error obtaining all superclasses of public class I am not sure if the PATH environment variable needs to be set somehow or if this is another error. Can you please comment on how to correct this mistake?

For Error reading line: org.apache.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18 Is ckjm only compatible with class files compiled under certain versions of the jvm? If so, which ones?

Thanks!

dspinellis commented 5 years ago

The CLASSPATH variable must allow the Java class loader to load all dependencies. You may need to update the distributed bcel to avoid the class reading problem. Please provide feedback if this helps.

jazzmuesli commented 4 years ago

Yes, adding all dependencies to java.class.path before calling MetricsFilter helps. I can wrap ckjm in a maven plugin and run it as mvn ckjm that would analyse target/*/.class.

geeksnet22 commented 4 years ago

What do you mean by adding all dependencies to java.class.path. Could you elaborate a bit more?

dspinellis commented 4 years ago

The path should contain all the directories and jar files used by the analyzed Java files.

geeksnet22 commented 4 years ago

I literally don't have any third party dependencies. Just a couple of directories containing simple classes and still it can't find the super class.

geeksnet22 commented 4 years ago

Never mind. I wasn't adding directory paths to CLASSPATH correctly. Thanks for help.

TheSav1101 commented 3 years ago

Hello, i get the same error when i try to use the program on some .class files with inner classes that are subclasses of the class that contains them. The strange thing is that it gives me an output for the problematic class.

Here is an example:

java -jar ckjm-1.9.jar -s ./*.class

Error obtaining all superclasses of class myAdapter.ListAdapter$SubListAdapter extends myAdapter.ListAdapter filename ./ListAdapter$SubListAdapter.class compiled from ListAdapter.java compiler version 55.0 access flags 32 constant pool 207 entries ACC_SUPER flag true

Attribute(s): SourceFile: ListAdapter.java (Unknown attribute NestHost: 00 0a) InnerClasses(2): private SubListAdapter=class myAdapter.ListAdapter$SubListAdapter of class myAdapter.ListAdapter private MyListIterator=class myAdapter.ListAdapter$MyListIterator of class myAdapter.ListAdapter

5 fields: private int startIndex private int endIndex private myAdapter.ListAdapter thisList private myAdapter.ListAdapter thisSubList final synthetic myAdapter.ListAdapter this$0

29 methods: private void (myAdapter.ListAdapter arg1) protected void (myAdapter.ListAdapter arg1, int arg2, int arg3, myAdapter.ListAdapter arg4) throws Exceptions: java.lang.IllegalArgumentException private void (myAdapter.ListAdapter arg1, myAdapter.ListAdapter$SubListAdapter arg2) private void updateSubList() public int size() public boolean isEmpty() public boolean contains(Object arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public myAdapter.HIterator iterator() public Object[] toArray() public Object[] toArray(Object[] arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public boolean add(Object arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public boolean remove(Object arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public boolean containsAll(myAdapter.HCollection arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public boolean addAll(myAdapter.HCollection arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public boolean addAll(int arg1, myAdapter.HCollection arg2) throws Exceptions: java.lang.IndexOutOfBoundsException, java.lang.NullPointerException, java.lang.ClassCastException public boolean removeAll(myAdapter.HCollection arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public boolean retainAll(myAdapter.HCollection arg1) throws Exceptions: java.lang.NullPointerException, java.lang.ClassCastException public void clear() public Object get(int arg1) throws Exceptions: java.lang.IndexOutOfBoundsException public Object set(int arg1, Object arg2) throws Exceptions: java.lang.IndexOutOfBoundsException, java.lang.NullPointerException, java.lang.ClassCastException public void add(int arg1, Object arg2) throws Exceptions: java.lang.NullPointerException, java.lang.IndexOutOfBoundsException, java.lang.ClassCastException public Object remove(int arg1) throws Exceptions: java.lang.IndexOutOfBoundsException public int lastIndexof(Object arg1) throws Exceptions: java.lang.NullPointerException public myAdapter.HListIterator listIterator() public myAdapter.HListIterator listIterator(int arg1) throws Exceptions: java.lang.IndexOutOfBoundsException public myAdapter.ListAdapter$SubListAdapter subList(int arg1, int arg2) public boolean equals(Object arg1) public int hashCode() public volatile synthetic myAdapter.HList subList(int arg1, int arg2)

myAdapter.HCollection 15 1 0 3 15 105 7 15 myAdapter.MapAdapter$BackingSetIterator 5 1 0 10 12 0 1 4 myAdapter.MapAdapter 17 1 0 14 45 4 3 17 myAdapter.ListAdapter$SubListAdapter 29 0 0 15 68 6 1 25 myAdapter.MapAdapter$MapAdapterEntry 10 1 0 10 21 13 1 9 myAdapter.HMap$HEntry 5 1 0 2 5 10 1 5 myAdapter.HMap 14 1 0 4 14 91 1 14 myAdapter.MapAdapter$BackingSet 18 1 0 20 57 37 3 17 myAdapter.HSet 15 1 0 4 15 105 3 15 myAdapter.ListAdapter 30 1 1 17 58 71 2 30 myAdapter.HIterator 3 1 0 2 3 3 9 3 myAdapter.ListAdapter$MyListIterator 12 1 0 13 26 0 2 11 myAdapter.HList 24 1 0 5 24 276 2 24 myAdapter.HListIterator 9 1 0 3 9 36 4 9