我想验证 2 个 JAR 之间的二进制兼容性。
按照这个答案中的建议,我使用了jboss tattletale,但它只能找到缺失的类。
如何查找是否缺少方法?有可能吗?
例如
“取决于”类Foo 取决于 Bar(像许多其他中产阶级工人一样)
import org.overlyusedclassnames.Bar
public class Foo{
public void someMethod(){
Bar tender = new Bar();
tender.getJohnnyRedLabel();
tender.getJohnnyBlueLabel(); //this method is new in the Bar class
}
}
“编译时间”类
package org.overlyusedclassnames;
/**
* @Since 1992
* Changes: added blue and gold Johnny Walker labels
*/
public class Bar {
public Drink getJohnnyRedLabel(){
return new JohnyWalkerFactory.get(RedLabel.class);
}
public Drink getJohnnyBlackLabel(){
return new JohnyWalkerFactory.get(BlackLabel.class);
}
public Drink getJohnnyGoldLabel(){
return new JohnyWalkerFactory.get(GoldLabel.class);
}
public Drink getJohnnyBlueLabel(){
return new JohnyWalkerFactory.get(BlueLabel.class);
}
}
现在想象一个旧的Bar jar 正在替换已编译的时间栏:
“运行时”类
package org.overlyusedclassnames;
/**
* @Since 1909
* Changes: added red and black Johnny Walker labels
*/
public class Bar {
public Drink getJohnnyRedLabel(){
return new JohnyWalkerFactory.get(RedLabel.class);
}
public Drink getJohnnyBlackLabel(){
return new JohnyWalkerFactory.get(BlackLabel.class);
}
}
有没有办法在不运行它并获得的情况下识别丢失的方法NoSuchMethodError
?
免责声明:这是对我自己的相关问题的重大改写,不可删除。我选择提出一个新问题,因为重新措辞会使当前的 2 个答案与主题完全无关。