[Clirr-devel] CVS: clirr/core/src/java/net/sf/clirr/core/internal/checks FieldSetCheck.java,1.4,1.5
Status: Alpha
Brought to you by:
lkuehne
From: Simon K. <s_k...@us...> - 2004-07-23 08:11:41
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27029/src/java/net/sf/clirr/core/internal/checks Modified Files: FieldSetCheck.java Log Message: Removing a field which is final and initialised with a constant value is a source incompatibility, but only a binary warning, because the constant will have been inlined in other classes. Index: FieldSetCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/FieldSetCheck.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FieldSetCheck.java 16 Jul 2004 10:36:38 -0000 1.4 +++ FieldSetCheck.java 23 Jul 2004 08:11:16 -0000 1.5 @@ -53,6 +53,7 @@ private static final Message MSG_FIELD_NOW_STATIC = new Message(6008); private static final Message MSG_FIELD_MORE_ACCESSIBLE = new Message(6009); private static final Message MSG_FIELD_LESS_ACCESSIBLE = new Message(6010); + private static final Message MSG_CONSTANT_FIELD_REMOVED = new Message(6011); private static final class FieldNameComparator implements Comparator { @@ -107,16 +108,27 @@ { if (scopeSelector.isSelected(bField)) { - // TODO: This is not an error if the field is a - // compile-time constant, because the value will - // have been inlined into callers [Q: is this - // mandatory, or only allowed by the java spec?]. - // See bugtracker #961222 - final String name = bField.getName(); - fireDiff(MSG_FIELD_REMOVED, - getSeverity(baselineClass, bField, Severity.ERROR), - baselineClass, bField, null); + if ((bField.getConstantValue() != null) && bField.isFinal()) + { + // Fields which are compile-time constants will have + // been inlined into callers; even though the field + // has been deleted, the caller will continue to use + // the old value. The result is therefore not + // technically a binary incompatibility, though it is + // a source-code incompatibility. + // See bugtracker #961222 + fireDiff(MSG_CONSTANT_FIELD_REMOVED, + getSeverity(baselineClass, bField, Severity.WARNING), + getSeverity(baselineClass, bField, Severity.ERROR), + baselineClass, bField, null); + } + else + { + fireDiff(MSG_FIELD_REMOVED, + getSeverity(baselineClass, bField, Severity.ERROR), + baselineClass, bField, null); + } } } else if (scopeSelector.isSelected(bField) || scopeSelector.isSelected(cField)) @@ -245,10 +257,23 @@ Field field, String[] args) { + fireDiff(msg, severity, severity, clazz, field, args); + } + + private void fireDiff( + Message msg, + Severity binarySeverity, + Severity sourceSeverity, + JavaClass clazz, + Field field, + String[] args) + { final String className = clazz.getClassName(); final ApiDifference diff = new ApiDifference( - msg, severity, className, null, field.getName(), args); + msg, + binarySeverity, sourceSeverity, + className, null, field.getName(), args); getApiDiffDispatcher().fireDiff(diff); } } |