Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing interface exception when only new class implements it #200

Closed
m-jarzebowski opened this issue Feb 23, 2018 · 3 comments
Closed

Missing interface exception when only new class implements it #200

m-jarzebowski opened this issue Feb 23, 2018 · 3 comments

Comments

@m-jarzebowski
Copy link

Hi,

when I try scan library with old and new classpath set I've got error message:

Could not load 'x.y.z': x.y.z. Please make sure that all libraries have been added to the classpath (OLD CLASSPATH=:/Users/xyz/old/jars/: / NEW CLASSPATH=:/Users/xyz/new/jars/:) or try the option '--ignore-missing-classes'.

This happens when class from new jar implements interface that is not present in old classpath (only present in new claaspath) but old jar class equivalent dose not implement any interface at all.

japicmp.compat.CompatibilityChanges line 650 looks like this:
interfaceClass = loadClass(implementedInterface.getFullyQualifiedName(), EnumSet.allOf(Classpath.class));
but probably should be:
interfaceClass = loadClass(implementedInterface.getFullyQualifiedName(), EnumSet.of(Classpath.NEW_CLASSPATH));

Could you fix this?

Cheers,
MJ

@siom79
Copy link
Owner

siom79 commented Mar 12, 2018

I have tried to reproduce your case. The first jar only contains one class MyClass while the second jar contains this class plus a new interface MyInterface which is implemented by the class. This is the output:

java -jar ../japicmp/japicmp/target/japicmp-0.11.1-SNAPSHOT-jar-with-dependencies.jar -o test-v1.jar -n test-v2.jar --old-classpath test-v1.jar --new-classpath test-v2.jar 
Comparing source compatibility of /home/user/test/test-v2.jar against /home/user/test/test-v1.jar
***  MODIFIED CLASS: PUBLIC japicmp.MyClass  (not serializable)
        ===  CLASS FILE FORMAT VERSION: 49.0 <- 49.0
        +++  NEW INTERFACE: japicmp.MyInterface
        ===  UNCHANGED CONSTRUCTOR: PUBLIC MyClass()
        ===  UNCHANGED METHOD: PUBLIC void foo()
+++  NEW INTERFACE: PUBLIC(+) ABSTRACT(+) japicmp.MyInterface  (not serializable)
        +++  CLASS FILE FORMAT VERSION: 49.0 <- n.a.

Can you provide more details about your case?

@m-jarzebowski
Copy link
Author

m-jarzebowski commented Mar 14, 2018

Ok. I try to clarify. I've invoked command like this:

java -jar japicmp-0.11.1-jar-with-dependencies.jar -n test-0.0.2.jar -o test-0.0.1.jar --new-classpath interfaces-0.0.2.jar --old-classpath interfaces-0.0.1.jar
E: Could not load 'org.example.interfaces.TestInterface': org.example.interfaces.TestInterface. Please make sure that all libraries have been added to the classpath (OLD CLASSPATH=:interfaces-0.0.1.jar: / NEW CLASSPATH=:interfaces-0.0.2.jar:) or try the option '--ignore-missing-classes'.

test-0.0.1.jar contains org/example/test/App.class:
public class App { }
test-0.0.2.jar contains org/example/test/App.class:
public class App implements TestInterface { }
interfaces-0.0.1.jar is empty (BTW japicmp forces to provide both old-classpath and new-classpath even if one of the lib versions don't need additional classpath).
interfaces-0.0.2.jar contains org/example/interfaces/TestInterface.class:
public interface TestInterface { }

siom79 added a commit that referenced this issue Mar 14, 2018
… be loaded from old and new classpath if specified separately
@siom79
Copy link
Owner

siom79 commented Mar 14, 2018

Thank you very much for the detailed description. With its help I could reproduce the issue.

The last commit resolves the problem that japicmp reports Could not load <class> if both classpaths were specified separately and the class could not be loaded over the old classpath.

@siom79 siom79 closed this as completed Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants