[Clirr-devel] CVS: clirr/core/src/java/net/sf/clirr/core/internal/checks MethodSetCheck.java,1.6,1.7
Status: Alpha
Brought to you by:
lkuehne
From: <lk...@us...> - 2005-08-01 07:21:53
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18083/src/java/net/sf/clirr/core/internal/checks Modified Files: MethodSetCheck.java Log Message: RFE #1241245, detect change of a method's final modifier Index: MethodSetCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/MethodSetCheck.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MethodSetCheck.java 20 Jul 2004 07:57:14 -0000 1.6 +++ MethodSetCheck.java 1 Aug 2005 07:21:42 -0000 1.7 @@ -61,6 +61,8 @@ private static final Message MSG_METHOD_ADDED = new Message(7011); private static final Message MSG_METHOD_ADDED_TO_INTERFACE = new Message(7012); private static final Message MSG_ABSTRACT_METHOD_ADDED = new Message(7013); + private static final Message MSG_METHOD_NOW_FINAL = new Message(7014); + private static final Message MSG_METHOD_NOW_NONFINAL = new Message(7015); private ScopeSelector scopeSelector; @@ -558,6 +560,7 @@ checkDeclaredExceptions(compatBaseline, baselineMethod, currentMethod); checkDeprecated(compatBaseline, baselineMethod, currentMethod); checkVisibility(compatBaseline, baselineMethod, currentMethod); + checkFinal(compatBaseline, baselineMethod, currentMethod); } private void checkParameterTypes(JavaClass compatBaseline, Method baselineMethod, Method currentMethod) @@ -663,6 +666,25 @@ } } + private void checkFinal( + JavaClass compatBaseline, + Method baselineMethod, Method currentMethod) + { + boolean bIsFinal = baselineMethod.isFinal(); + boolean cIsFinal = currentMethod.isFinal(); + + if (bIsFinal && !cIsFinal) + { + fireDiff(MSG_METHOD_NOW_NONFINAL, + Severity.INFO, compatBaseline, baselineMethod, null); + } + else if (!bIsFinal && cIsFinal) + { + fireDiff(MSG_METHOD_NOW_FINAL, + Severity.ERROR, compatBaseline, baselineMethod, null); + } + } + /** * Creates a human readable String that is similar to the method signature * and identifies the method within a class. |