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

Covariant return type causes false positive for method removal due to return type change. #50

Open
busbey opened this issue Sep 7, 2018 · 0 comments

Comments

@busbey
Copy link

busbey commented Sep 7, 2018

Over in Apache HBase we had a change (509c1b63) that added a method to a supertype of a class such that the original class' method became an override via covariant return type.

In summary, before the change:

class Query {}

class Scan extends Query {
  public Scan setLoadColumnFamiliesOnDemand(boolean value);
}

and after the change:

class Query {
  public Query setLoadColumnFamiliesOnDemand(boolean value);
}

class Scan extends Query {
  public Scan setLoadColumnFamiliesOnDemand(boolean value);
}

Using japi-compliance-checker 2.4, this gets reported as a change in return type that will cause a High Severity binary compatibility problem for MethodNotFoundException and a Medium Severity source compatibility problem for downstream users.

e.g.

Problems with Methods, High Severity  1 


  hbase-client-1.2.6.jar, Scan.class
  package org.apache.hadoop.hbase.client
  [+] Scan.setLoadColumnFamiliesOnDemand ( boolean value )  :  Scan  1   
 
  org/apache/hadoop/hbase/client/Scan.setLoadColumnFamiliesOnDemand:(Z)Lorg/apache/hadoop/hbase/client/Scan;
           
ChangeEffect
1Return value type has been changed from Scan to Query.This method has been removed because the return type is part of the method signature. A client program may be interrupted by NoSuchMethodError exception.

 
Examining the class file for the updated Scan class shows that since the method now has a covariant return type two method signatures are included:

busbey$ javap -cp target/compat-check/dst/hbase-client/target/hbase-client-1.2.7.jar org.apache.hadoop.hbase.client.Scan | grep setLoadColumnFamiliesOnDemand
  public org.apache.hadoop.hbase.client.Scan setLoadColumnFamiliesOnDemand(boolean);
  public org.apache.hadoop.hbase.client.Query setLoadColumnFamiliesOnDemand(boolean);

japi-compliance-checker appears to mistakenly just pick up the second method signature and thus the compatibility issues.

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

1 participant