clirr-devel Mailing List for Clirr (Page 13)
Status: Alpha
Brought to you by:
lkuehne
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(23) |
Nov
|
Dec
(25) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(9) |
Feb
|
Mar
|
Apr
|
May
(76) |
Jun
(207) |
Jul
(242) |
Aug
(42) |
Sep
(33) |
Oct
|
Nov
(7) |
Dec
(1) |
2005 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(66) |
Sep
(38) |
Oct
(6) |
Nov
|
Dec
(2) |
2006 |
Jan
(17) |
Feb
(5) |
Mar
(28) |
Apr
(6) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(7) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(33) |
Jun
(4) |
Jul
(3) |
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
|
2008 |
Jan
(4) |
Feb
(3) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
(6) |
Aug
(8) |
Sep
(5) |
Oct
(20) |
Nov
(7) |
Dec
(9) |
2009 |
Jan
(8) |
Feb
(3) |
Mar
(20) |
Apr
(10) |
May
(40) |
Jun
(11) |
Jul
(23) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(2) |
2010 |
Jan
(5) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
(6) |
May
(22) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(2) |
2014 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2015 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <lk...@us...> - 2005-09-05 21:15:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27683/src/java/net/sf/clirr/core Modified Files: Checker.java Log Message: Moved BCEL out of core Checker and only use the JavaType interface there. Using BCEL is now an implementation detail of the Ant and CLI frontends, and IDE plugins might use a completely different implementation. Index: Checker.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/Checker.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Checker.java 26 Aug 2005 05:35:53 -0000 1.8 +++ Checker.java 5 Sep 2005 21:14:52 -0000 1.9 @@ -22,37 +22,21 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Enumeration; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.MalformedURLException; -import java.net.URLClassLoader; -import net.sf.clirr.core.internal.bcel.BcelJavaType; +import net.sf.clirr.core.internal.ApiDiffDispatcher; +import net.sf.clirr.core.internal.ClassChangeCheck; +import net.sf.clirr.core.internal.CoIterator; +import net.sf.clirr.core.internal.NameComparator; import net.sf.clirr.core.internal.checks.ClassHierarchyCheck; -import net.sf.clirr.core.internal.checks.ClassScopeCheck; import net.sf.clirr.core.internal.checks.ClassModifierCheck; +import net.sf.clirr.core.internal.checks.ClassScopeCheck; +import net.sf.clirr.core.internal.checks.FieldSetCheck; import net.sf.clirr.core.internal.checks.GenderChangeCheck; import net.sf.clirr.core.internal.checks.InterfaceSetCheck; -import net.sf.clirr.core.internal.checks.FieldSetCheck; import net.sf.clirr.core.internal.checks.MethodSetCheck; -import net.sf.clirr.core.internal.ApiDiffDispatcher; -import net.sf.clirr.core.internal.ClassChangeCheck; -import net.sf.clirr.core.internal.CoIterator; -import net.sf.clirr.core.internal.ExceptionUtil; -import net.sf.clirr.core.internal.NameComparator; import net.sf.clirr.core.spi.JavaType; import net.sf.clirr.core.spi.Scope; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.util.Repository; -import org.apache.bcel.util.ClassLoaderRepository; - /** * This is the main class to be used by Clirr frontends, * it implements the checking functionality of Clirr. @@ -137,177 +121,6 @@ } /** - * Compare the classes in the two sets of jars and report any differences - * to this object's DiffListener object. If the classes in those jars reference - * third party classes (e.g. as base class, implemented interface or method param), - * such third party classes must be made available via the xyzThirdPartyLoader - * classloaders. - * - * @param origJars is a set of jars containing the "original" versions of - * the classes to be compared. - * - * @param newJars is a set of jars containing the new versions of the - * classes to be compared. - * - * @param origThirdPartyLoader is a classloader that provides third party classes - * which are referenced by origJars. - * - * @param newThirdPartyLoader is a classloader that provides third party classes - * which are referenced by newJars. - * - * @param classSelector is an object which determines which classes from the - * old and new jars are to be compared. This parameter may be null, in - * which case all classes in the old and new jars are compared. - */ - public void reportDiffs( - File[] origJars, File[] newJars, - ClassLoader origThirdPartyLoader, ClassLoader newThirdPartyLoader, - ClassFilter classSelector) - throws CheckerException - { - if (classSelector == null) - { - // create a class selector that selects all classes - classSelector = new ClassSelector(ClassSelector.MODE_UNLESS); - } - - final JavaType[] origClasses = - createClassSet(origJars, origThirdPartyLoader, classSelector); - - final JavaType[] newClasses = - createClassSet(newJars, newThirdPartyLoader, classSelector); - - reportDiffs(origClasses, newClasses); - } - - /** - * Creates a set of classes to check. - * - * @param jarFiles a set of jar filed to scan for class files. - * - * @param thirdPartyClasses loads classes that are referenced - * by the classes in the jarFiles - * - * @param classSelector is an object which determines which classes from the - * old and new jars are to be compared. This parameter may be null, in - * which case all classes in the old and new jars are compared. - */ - private static JavaType[] createClassSet( - File[] jarFiles, ClassLoader thirdPartyClasses, ClassFilter classSelector) - throws CheckerException - { - if (classSelector == null) - { - // create a class selector that selects all classes - classSelector = new ClassSelector(ClassSelector.MODE_UNLESS); - } - - ClassLoader classLoader = createClassLoader(jarFiles, thirdPartyClasses); - - Repository repository = new ClassLoaderRepository(classLoader); - - List selected = new ArrayList(); - - for (int i = 0; i < jarFiles.length; i++) - { - File jarFile = jarFiles[i]; - ZipFile zip = null; - try - { - zip = new ZipFile(jarFile, ZipFile.OPEN_READ); - } - catch (IOException ex) - { - throw new CheckerException( - "Cannot open " + jarFile + " for reading", ex); - } - Enumeration enumEntries = zip.entries(); - while (enumEntries.hasMoreElements()) - { - ZipEntry zipEntry = (ZipEntry) enumEntries.nextElement(); - if (!zipEntry.isDirectory() && zipEntry.getName().endsWith(".class")) - { - JavaClass clazz = extractClass(zipEntry, zip, repository); - if (classSelector.isSelected(clazz)) - { - selected.add(new BcelJavaType(clazz)); - repository.storeClass(clazz); - } - } - } - } - - JavaType[] ret = new JavaType[selected.size()]; - selected.toArray(ret); - return ret; - } - - private static JavaClass extractClass( - ZipEntry zipEntry, ZipFile zip, Repository repository) - throws CheckerException - { - String name = zipEntry.getName(); - InputStream is = null; - try - { - is = zip.getInputStream(zipEntry); - - ClassParser parser = new ClassParser(is, name); - JavaClass clazz = parser.parse(); - clazz.setRepository(repository); - return clazz; - } - catch (IOException ex) - { - throw new CheckerException( - "Cannot read " + zipEntry.getName() + " from " + zip.getName(), - ex); - } - finally - { - if (is != null) - { - try - { - is.close(); - } - catch (IOException ex) - { - throw new CheckerException("Cannot close " + zip.getName(), ex); - } - } - } - } - - private static ClassLoader createClassLoader( - File[] jarFiles, ClassLoader thirdPartyClasses) - { - final URL[] jarUrls = new URL[jarFiles.length]; - for (int i = 0; i < jarFiles.length; i++) - { - File jarFile = jarFiles[i]; - try - { - URL url = jarFile.toURL(); - jarUrls[i] = url; - } - catch (MalformedURLException ex) - { - // this should never happen - final IllegalArgumentException illegalArgumentException = - new IllegalArgumentException( - "Cannot create classloader with jar file " + jarFile); - ExceptionUtil.initCause(illegalArgumentException, ex); - throw illegalArgumentException; - } - } - final URLClassLoader jarsLoader = new URLClassLoader(jarUrls, thirdPartyClasses); - - return jarsLoader; - } - - - /** * Checks two sets of classes for api changes and reports * them to the DiffListeners. * @param compatibilityBaseline the classes that form the @@ -315,7 +128,7 @@ * @param currentVersion the classes that are checked for * compatibility with compatibilityBaseline */ - private void reportDiffs( + public void reportDiffs( JavaType[] compatibilityBaseline, JavaType[] currentVersion) throws CheckerException { |
From: <lk...@us...> - 2005-09-05 21:15:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/cli In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27683/src/java/net/sf/clirr/cli Modified Files: Clirr.java Log Message: Moved BCEL out of core Checker and only use the JavaType interface there. Using BCEL is now an implementation detail of the Ant and CLI frontends, and IDE plugins might use a completely different implementation. Index: Clirr.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/cli/Clirr.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Clirr.java 26 Aug 2005 05:35:53 -0000 1.5 +++ Clirr.java 5 Sep 2005 21:14:52 -0000 1.6 @@ -25,6 +25,8 @@ import net.sf.clirr.core.PlainDiffListener; import net.sf.clirr.core.XmlDiffListener; import net.sf.clirr.core.DiffListener; +import net.sf.clirr.core.internal.bcel.BcelTypeArrayBuilder; +import net.sf.clirr.core.spi.JavaType; import net.sf.clirr.core.spi.Scope; import org.apache.commons.cli.BasicParser; @@ -165,7 +167,13 @@ try { - checker.reportDiffs(origJars, newJars, loader1, loader2, classSelector); + final JavaType[] origClasses = + BcelTypeArrayBuilder.createClassSet(origJars, loader1, classSelector); + + final JavaType[] newClasses = + BcelTypeArrayBuilder.createClassSet(newJars, loader2, classSelector); + + checker.reportDiffs(origClasses, newClasses); } catch (CheckerException ex) { |
From: <lk...@us...> - 2005-09-05 21:15:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/ant In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27683/src/java/net/sf/clirr/ant Modified Files: AntTask.java Log Message: Moved BCEL out of core Checker and only use the JavaType interface there. Using BCEL is now an implementation detail of the Ant and CLI frontends, and IDE plugins might use a completely different implementation. Index: AntTask.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/ant/AntTask.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AntTask.java 3 Aug 2005 17:16:06 -0000 1.5 +++ AntTask.java 5 Sep 2005 21:14:52 -0000 1.6 @@ -35,6 +35,8 @@ import net.sf.clirr.core.ClassSelector; import net.sf.clirr.core.ClassFilter; import net.sf.clirr.core.internal.ExceptionUtil; +import net.sf.clirr.core.internal.bcel.BcelTypeArrayBuilder; +import net.sf.clirr.core.spi.JavaType; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; @@ -294,8 +296,14 @@ checker.addDiffListener(counter); try { - checker.reportDiffs( - origJars, newJars, origThirdPartyLoader, newThirdPartyLoader, buildClassFilter()); + ClassFilter classSelector = buildClassFilter(); + final JavaType[] origClasses = + BcelTypeArrayBuilder.createClassSet(origJars, origThirdPartyLoader, classSelector); + + final JavaType[] newClasses = + BcelTypeArrayBuilder.createClassSet(newJars, newThirdPartyLoader, classSelector); + + checker.reportDiffs(origClasses, newClasses); } catch (CheckerException ex) { |
From: <lk...@us...> - 2005-09-05 21:15:00
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/bcel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27683/src/java/net/sf/clirr/core/internal/bcel Added Files: BcelTypeArrayBuilder.java Log Message: Moved BCEL out of core Checker and only use the JavaType interface there. Using BCEL is now an implementation detail of the Ant and CLI frontends, and IDE plugins might use a completely different implementation. --- NEW FILE --- package net.sf.clirr.core.internal.bcel; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import net.sf.clirr.core.CheckerException; import net.sf.clirr.core.ClassFilter; import net.sf.clirr.core.ClassSelector; import net.sf.clirr.core.internal.ExceptionUtil; import net.sf.clirr.core.spi.JavaType; import org.apache.bcel.classfile.ClassParser; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.util.ClassLoaderRepository; import org.apache.bcel.util.Repository; public final class BcelTypeArrayBuilder { /** * Disallow instantiation. */ private BcelTypeArrayBuilder() { } /** * Creates a set of classes to check. * * @param jarFiles a set of jar filed to scan for class files. * * @param thirdPartyClasses loads classes that are referenced * by the classes in the jarFiles * * @param classSelector is an object which determines which classes from the * old and new jars are to be compared. This parameter may be null, in * which case all classes in the old and new jars are compared. */ public static JavaType[] createClassSet( File[] jarFiles, ClassLoader thirdPartyClasses, ClassFilter classSelector) throws CheckerException { if (classSelector == null) { // create a class selector that selects all classes classSelector = new ClassSelector(ClassSelector.MODE_UNLESS); } ClassLoader classLoader = createClassLoader(jarFiles, thirdPartyClasses); Repository repository = new ClassLoaderRepository(classLoader); List selected = new ArrayList(); for (int i = 0; i < jarFiles.length; i++) { File jarFile = jarFiles[i]; ZipFile zip = null; try { zip = new ZipFile(jarFile, ZipFile.OPEN_READ); } catch (IOException ex) { throw new CheckerException( "Cannot open " + jarFile + " for reading", ex); } Enumeration enumEntries = zip.entries(); while (enumEntries.hasMoreElements()) { ZipEntry zipEntry = (ZipEntry) enumEntries.nextElement(); if (!zipEntry.isDirectory() && zipEntry.getName().endsWith(".class")) { JavaClass clazz = extractClass(zipEntry, zip, repository); if (classSelector.isSelected(clazz)) { selected.add(new BcelJavaType(clazz)); repository.storeClass(clazz); } } } } JavaType[] ret = new JavaType[selected.size()]; selected.toArray(ret); return ret; } private static ClassLoader createClassLoader( File[] jarFiles, ClassLoader thirdPartyClasses) { final URL[] jarUrls = new URL[jarFiles.length]; for (int i = 0; i < jarFiles.length; i++) { File jarFile = jarFiles[i]; try { URL url = jarFile.toURL(); jarUrls[i] = url; } catch (MalformedURLException ex) { // this should never happen final IllegalArgumentException illegalArgumentException = new IllegalArgumentException( "Cannot create classloader with jar file " + jarFile); ExceptionUtil.initCause(illegalArgumentException, ex); throw illegalArgumentException; } } final URLClassLoader jarsLoader = new URLClassLoader(jarUrls, thirdPartyClasses); return jarsLoader; } private static JavaClass extractClass( ZipEntry zipEntry, ZipFile zip, Repository repository) throws CheckerException { String name = zipEntry.getName(); InputStream is = null; try { is = zip.getInputStream(zipEntry); ClassParser parser = new ClassParser(is, name); JavaClass clazz = parser.parse(); clazz.setRepository(repository); return clazz; } catch (IOException ex) { throw new CheckerException( "Cannot read " + zipEntry.getName() + " from " + zip.getName(), ex); } finally { if (is != null) { try { is.close(); } catch (IOException ex) { throw new CheckerException("Cannot close " + zip.getName(), ex); } } } } } |
From: <lk...@us...> - 2005-08-27 15:11:42
|
Update of /cvsroot/clirr/clirr/maven In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19218 Modified Files: project.xml Log Message: use clirr 0.6-dev and changed group id Index: project.xml =================================================================== RCS file: /cvsroot/clirr/clirr/maven/project.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- project.xml 8 Aug 2005 13:21:20 -0000 1.4 +++ project.xml 27 Aug 2005 15:11:34 -0000 1.5 @@ -8,7 +8,7 @@ <!-- Note: Although we inherit from project.xml, we still cannot remove the <currentVersion> tag as this project.xml is parsed at runtime whenever our plugin is called. --> - <currentVersion>0.5</currentVersion> + <currentVersion>0.6-dev</currentVersion> <package>net.sf.clirr.maven</package> <description>Maven plugin for Clirr</description> @@ -20,7 +20,7 @@ </repository> <dependencies> <dependency> - <groupId>clirr</groupId> + <groupId>net.sf.clirr</groupId> <artifactId>clirr-core</artifactId> <version>${pom.currentVersion}</version> </dependency> |
From: <lk...@us...> - 2005-08-27 11:04:41
|
Update of /cvsroot/clirr/clirr/core/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7171/xdocs Modified Files: changes.xml Log Message: fix for bug #1267189, class exclusion via <apiclasses> is broken on Windows Index: changes.xml =================================================================== RCS file: /cvsroot/clirr/clirr/core/xdocs/changes.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- changes.xml 26 Aug 2005 05:35:53 -0000 1.9 +++ changes.xml 27 Aug 2005 11:04:33 -0000 1.10 @@ -16,6 +16,10 @@ sources, so a Clirr IDE plugin could use that (via an adapter) and would not require a full compile before running Clirr. </action> + <action dev="lkuehne" type="fix"> + <!-- Bug #1267189--> + Ant task: Class exclusion via apiclasses subelement was broken on Windows. + </action> <action dev="lkuehne" type="fix"> Improved test coverage. </action> |
From: <lk...@us...> - 2005-08-27 10:34:35
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/ant In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1613/src/java/net/sf/clirr/ant Modified Files: PatternSetFilter.java Log Message: fix for bug #1267189, class exclusion via <apiclasses> is broken on Windows Index: PatternSetFilter.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/ant/PatternSetFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PatternSetFilter.java 7 Aug 2005 14:40:12 -0000 1.3 +++ PatternSetFilter.java 27 Aug 2005 10:34:22 -0000 1.4 @@ -57,7 +57,7 @@ // The patternset evaluation code below was copied from Apache Ant's Expand task. // I feel this code should be available as a library function inside Ant somewhere... String className = clazz.getClassName(); - String name = className.replace('.', '/'); + String name = className.replace('.', File.separatorChar); if (patternSets == null || patternSets.isEmpty()) |
From: <lak...@t-...> - 2005-08-26 06:00:17
|
Simon Kitching wrote: >On Mon, 2005-08-22 at 21:05 +0200, Lars Kühne wrote: > > >>Hi, >> >>if nobody objects within the next few days, I will commit changes to >>clirr-core that introduce an SPI for providing the Java code structure. >>[...] >> >Sounds fine > OK, done. > - though I would also be happy with just swapping to use ASM >directly. > > > You mean implementing our checks directly against ASM? I considered that, but I think an IDE plugin would provide real value. I'm not sure that the interface design is ideal, though - this is only a first shot. >I've been wondering whether we should look at restructuring the code to >work more like an asm "visitor" or how checkstyle works than the current >layout, because last I looked the method tests were getting rather >complex. > Yes, they are too complex. > But of course last time I looked was quite a while ago! I >presume your new code will still essentially encapsulate an in-memory >"model" of classes that the checks then inspect rather that try to be >more ASM-ish?? > > > Currently yes, but now that we have our own interfaces we are no longer limited by BCEL and can easily add an accept() method to them. Not sure that the visitor pattern is ideal, though. The checks are dependent on each other in the sense that some checks are not executed if other checks detect a "higher level" problem. Visitor doesn't cover this well, to me this sounds like we should organize our checks as a chain of responsibility. Haven't thought this through completely however... Thanks for your feedback, Lars |
From: <lk...@us...> - 2005-08-26 05:36:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/src/java/net/sf/clirr/core/internal Modified Files: AbstractDiffReporter.java ClassChangeCheck.java Removed Files: JavaClassNameComparator.java Log Message: moved clirr implementation to new SPI infrastructure Index: AbstractDiffReporter.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/AbstractDiffReporter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractDiffReporter.java 3 Aug 2005 17:16:14 -0000 1.4 +++ AbstractDiffReporter.java 26 Aug 2005 05:35:52 -0000 1.5 @@ -22,11 +22,10 @@ import net.sf.clirr.core.ApiDifference; import net.sf.clirr.core.Severity; import net.sf.clirr.core.Message; -import net.sf.clirr.core.ScopeSelector; -import net.sf.clirr.core.CheckerException; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.JavaClass; +import net.sf.clirr.core.spi.JavaType; +import net.sf.clirr.core.spi.Field; +import net.sf.clirr.core.spi.Method; +import net.sf.clirr.core.spi.Scope; public abstract class AbstractDiffReporter { @@ -73,34 +72,17 @@ * @return param sev if the class is public/protected, and Severity.INFO * if the class is package or private scope. */ - protected final Severity getSeverity(JavaClass clazz, Severity sev) + protected final Severity getSeverity(JavaType clazz, Severity sev) { - // use ScopeSelector, not isPublic/isProtected, because the latter - // methods don't correctly handle scopes of nested classes. - ScopeSelector.Scope scope; + Scope scope = clazz.getEffectiveScope(); - try + if (scope.isLessVisibleThan(Scope.PROTECTED)) { - scope = ScopeSelector.getClassScope(clazz); - } - catch (CheckerException ex) - { - // Note: this should never happen. If it does, it probably - // means clirr has been passed a severely-stuffed-up jar - // for analysis. - log(MSG_UNABLE_TO_DETERMINE_CLASS_SCOPE, - Severity.ERROR, clazz.getClassName(), null, null, null); - return sev; - } - - if ((scope == ScopeSelector.SCOPE_PUBLIC) - || (scope == ScopeSelector.SCOPE_PROTECTED)) - { - return sev; + return Severity.INFO; } else { - return Severity.INFO; + return sev; } } @@ -128,9 +110,10 @@ * @return param sev if the method is public/protected, and Severity.INFO * if the method is package or private scope. */ - protected final Severity getSeverity(JavaClass clazz, Method method, Severity sev) + protected final Severity getSeverity(JavaType clazz, Method method, Severity sev) { - if (method.isPublic() || method.isProtected()) + + if (!method.getDeclaredScope().isLessVisibleThan(Scope.PROTECTED)) { return getSeverity(clazz, sev); } @@ -164,9 +147,9 @@ * @return param sev if the field is public/protected, and Severity.INFO * if the field is package or private scope. */ - protected final Severity getSeverity(JavaClass clazz, Field field, Severity sev) + protected final Severity getSeverity(JavaType clazz, Field field, Severity sev) { - if (field.isPublic() || field.isProtected()) + if (!field.getDeclaredScope().isLessVisibleThan(Scope.PROTECTED)) { return getSeverity(clazz, sev); } Index: ClassChangeCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/ClassChangeCheck.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ClassChangeCheck.java 3 Aug 2005 17:16:25 -0000 1.2 +++ ClassChangeCheck.java 26 Aug 2005 05:35:53 -0000 1.3 @@ -19,10 +19,10 @@ package net.sf.clirr.core.internal; -import org.apache.bcel.classfile.JavaClass; import net.sf.clirr.core.CheckerException; +import net.sf.clirr.core.spi.JavaType; public interface ClassChangeCheck { - boolean check(JavaClass compatBaseline, JavaClass currentVersion) throws CheckerException; + boolean check(JavaType compatBaseline, JavaType currentVersion) throws CheckerException; } |
From: <lk...@us...> - 2005-08-26 05:36:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/src/java/net/sf/clirr/core/internal/checks Modified Files: FieldSetCheck.java ClassScopeCheck.java MethodSetCheck.java InterfaceSetCheck.java ClassModifierCheck.java ClassHierarchyCheck.java GenderChangeCheck.java Log Message: moved clirr implementation to new SPI infrastructure Index: FieldSetCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/FieldSetCheck.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FieldSetCheck.java 3 Aug 2005 17:16:28 -0000 1.7 +++ FieldSetCheck.java 26 Aug 2005 05:35:52 -0000 1.8 @@ -25,13 +25,14 @@ import net.sf.clirr.core.internal.AbstractDiffReporter; import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.CoIterator; +import net.sf.clirr.core.internal.NameComparator; +import net.sf.clirr.core.spi.Field; +import net.sf.clirr.core.spi.JavaType; +import net.sf.clirr.core.spi.Scope; import net.sf.clirr.core.ApiDifference; import net.sf.clirr.core.Severity; import net.sf.clirr.core.ScopeSelector; import net.sf.clirr.core.Message; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Field; -import org.apache.bcel.classfile.ConstantValue; /** * Checks the fields of a class. @@ -55,21 +56,7 @@ 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 - { - public int compare(Object o1, Object o2) - { - Field f1 = (Field) o1; - Field f2 = (Field) o2; - - final String name1 = f1.getName(); - final String name2 = f2.getName(); - - return name1.compareTo(name2); - } - } - - private static final Comparator COMPARATOR = new FieldNameComparator(); + private static final Comparator COMPARATOR = new NameComparator(); private ScopeSelector scopeSelector; public FieldSetCheck(ApiDiffDispatcher dispatcher, ScopeSelector scopeSelector) @@ -78,7 +65,7 @@ this.scopeSelector = scopeSelector; } - public final boolean check(JavaClass baselineClass, JavaClass currentClass) + public final boolean check(JavaType baselineClass, JavaType currentClass) { final Field[] baselineFields = baselineClass.getFields(); final Field[] currentFields = currentClass.getFields(); @@ -97,7 +84,7 @@ { if (scopeSelector.isSelected(cField)) { - String scope = ScopeSelector.getScopeDesc(cField); + String scope = cField.getDeclaredScope().getDesc(); fireDiff(MSG_FIELD_ADDED, Severity.INFO, currentClass, cField, new String[]{scope}); @@ -141,19 +128,19 @@ return true; } - private void checkForConstantValueChange(Field bField, Field cField, JavaClass currentClass) + private void checkForConstantValueChange(Field bField, Field cField, JavaType currentClass) { if (!(bField.isStatic() && bField.isFinal() && cField.isStatic() && cField.isFinal())) { return; } - final ConstantValue bVal = bField.getConstantValue(); + final Object bVal = bField.getConstantValue(); if (bVal != null) { final String bValRep = bVal.toString(); - final ConstantValue cVal = cField.getConstantValue(); + final Object cVal = cField.getConstantValue(); if (cVal == null) { // TODO: also check whether old field is final. If it's not @@ -182,7 +169,7 @@ } } - private void checkForTypeChange(Field bField, Field cField, JavaClass currentClass) + private void checkForTypeChange(Field bField, Field cField, JavaType currentClass) { final String bSig = bField.getType().toString(); final String cSig = cField.getType().toString(); @@ -195,7 +182,7 @@ } } - private void checkForModifierChange(Field bField, Field cField, JavaClass clazz) + private void checkForModifierChange(Field bField, Field cField, JavaType clazz) { if (bField.isFinal() && !cField.isFinal()) { @@ -228,10 +215,10 @@ // TODO: What about volatile? } - private void checkForVisibilityChange(Field bField, Field cField, JavaClass clazz) + private void checkForVisibilityChange(Field bField, Field cField, JavaType clazz) { - ScopeSelector.Scope bScope = ScopeSelector.getScope(bField); - ScopeSelector.Scope cScope = ScopeSelector.getScope(cField); + Scope bScope = bField.getEffectiveScope(); + Scope cScope = cField.getEffectiveScope(); if (cScope.isMoreVisibleThan(bScope)) { @@ -251,7 +238,7 @@ private void fireDiff( Message msg, Severity severity, - JavaClass clazz, + JavaType clazz, Field field, String[] args) { @@ -262,11 +249,11 @@ Message msg, Severity binarySeverity, Severity sourceSeverity, - JavaClass clazz, + JavaType clazz, Field field, String[] args) { - final String className = clazz.getClassName(); + final String className = clazz.getName(); final ApiDifference diff = new ApiDifference( msg, Index: ClassScopeCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/ClassScopeCheck.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ClassScopeCheck.java 3 Aug 2005 17:16:28 -0000 1.4 +++ ClassScopeCheck.java 26 Aug 2005 05:35:52 -0000 1.5 @@ -25,9 +25,8 @@ import net.sf.clirr.core.internal.AbstractDiffReporter; import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; -import net.sf.clirr.core.CheckerException; - -import org.apache.bcel.classfile.JavaClass; +import net.sf.clirr.core.spi.JavaType; +import net.sf.clirr.core.spi.Scope; /** * Detects changes in class access declaration, for both "top-level" classes, @@ -68,33 +67,10 @@ } /** {@inheritDoc} */ - public boolean check(JavaClass compatBaseline, JavaClass currentVersion) + public boolean check(JavaType compatBaseline, JavaType currentVersion) { - ScopeSelector.Scope bScope; - try - { - bScope = ScopeSelector.getClassScope(compatBaseline); - } - catch (CheckerException ex) - { - log(MSG_ERROR_DETERMINING_SCOPE_OLD, - Severity.ERROR, compatBaseline.getClassName(), null, null, - new String[] {ex.getMessage()}); - return false; - } - - ScopeSelector.Scope cScope; - try - { - cScope = ScopeSelector.getClassScope(currentVersion); - } - catch (CheckerException ex) - { - log(MSG_ERROR_DETERMINING_SCOPE_NEW, - Severity.ERROR, compatBaseline.getClassName(), null, null, - new String[] {ex.getMessage()}); - return false; - } + Scope bScope = compatBaseline.getEffectiveScope(); + Scope cScope = currentVersion.getEffectiveScope(); if (!scopeSelector.isSelected(bScope) && !scopeSelector.isSelected(cScope)) { @@ -109,7 +85,7 @@ String[] args = {bScope.getDesc(), cScope.getDesc()}; log(MSG_SCOPE_INCREASED, - Severity.INFO, compatBaseline.getClassName(), null, null, args); + Severity.INFO, compatBaseline.getName(), null, null, args); } else if (cScope.isLessVisibleThan(bScope)) { @@ -117,7 +93,7 @@ log(MSG_SCOPE_DECREASED, getSeverity(compatBaseline, Severity.ERROR), - compatBaseline.getClassName(), null, null, args); + compatBaseline.getName(), null, null, args); } // Apply further checks only if both versions of the class have scopes Index: MethodSetCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/MethodSetCheck.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MethodSetCheck.java 3 Aug 2005 17:16:31 -0000 1.8 +++ MethodSetCheck.java 26 Aug 2005 05:35:52 -0000 1.9 @@ -27,10 +27,9 @@ import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; import net.sf.clirr.core.internal.CoIterator; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; -import org.apache.bcel.generic.Type; +import net.sf.clirr.core.spi.JavaType; +import net.sf.clirr.core.spi.Method; +import net.sf.clirr.core.spi.Scope; import java.util.ArrayList; import java.util.HashMap; @@ -78,7 +77,7 @@ this.scopeSelector = scopeSelector; } - public final boolean check(JavaClass compatBaseline, JavaClass currentVersion) + public final boolean check(JavaType compatBaseline, JavaType currentVersion) { // Dont't report method problems when gender has changed, as // really the whole API is a pile of crap then - let GenderChange check @@ -166,9 +165,9 @@ * this method. */ private void filterSoftMatchedMethods( - JavaClass compatBaseline, + JavaType compatBaseline, List baselineMethods, - JavaClass currentVersion, + JavaType currentVersion, List currentMethods) { for (Iterator bIter = baselineMethods.iterator(); bIter.hasNext();) @@ -236,9 +235,9 @@ */ private void filterChangedMethods( String methodName, - JavaClass compatBaseline, + JavaType compatBaseline, List baselineMethods, - JavaClass currentVersion, + JavaType currentVersion, List currentMethods) { // ok, we now have to deal with the tricky cases, where it is not @@ -292,8 +291,8 @@ private int distance(Method m1, Method m2) { - final Type[] m1Args = m1.getArgumentTypes(); - final Type[] m2Args = m2.getArgumentTypes(); + final JavaType[] m1Args = m1.getArgumentTypes(); + final JavaType[] m2Args = m2.getArgumentTypes(); if (m1Args.length != m2Args.length) { @@ -317,12 +316,12 @@ * @param clazz class where search starts * @return class name of a superclass of clazz, might be null */ - private String findSuperClassWithSignature(String methodSignature, JavaClass clazz) + private String findSuperClassWithSignature(String methodSignature, JavaType clazz) { - final JavaClass[] superClasses = clazz.getSuperClasses(); + final JavaType[] superClasses = clazz.getSuperClasses(); for (int i = 0; i < superClasses.length; i++) { - JavaClass superClass = superClasses[i]; + JavaType superClass = superClasses[i]; final Method[] superMethods = superClass.getMethods(); for (int j = 0; j < superMethods.length; j++) { @@ -330,7 +329,7 @@ final String superMethodSignature = getMethodId(superClass, superMethod); if (methodSignature.equals(superMethodSignature)) { - return superClass.getClassName(); + return superClass.getName(); } } @@ -344,12 +343,12 @@ * @param clazz class where search starts * @return class name of a superinterface of clazz, might be null */ - private String findSuperInterfaceWithSignature(String methodSignature, JavaClass clazz) + private String findSuperInterfaceWithSignature(String methodSignature, JavaType clazz) { - final JavaClass[] superClasses = clazz.getAllInterfaces(); + final JavaType[] superClasses = clazz.getAllInterfaces(); for (int i = 0; i < superClasses.length; i++) { - JavaClass superClass = superClasses[i]; + JavaType superClass = superClasses[i]; final Method[] superMethods = superClass.getMethods(); for (int j = 0; j < superMethods.length; j++) { @@ -357,7 +356,7 @@ final String superMethodSignature = getMethodId(superClass, superMethod); if (methodSignature.equals(superMethodSignature)) { - return superClass.getClassName(); + return superClass.getName(); } } @@ -369,9 +368,9 @@ * Given a list of methods, report each one as being removed. */ private void reportMethodsRemoved( - JavaClass baselineClass, + JavaType baselineClass, List baselineMethods, - JavaClass currentClass) + JavaType currentClass) { for (Iterator i = baselineMethods.iterator(); i.hasNext();) { @@ -387,9 +386,9 @@ * @param currentClass the superclass where the method is now available, might be null */ private void reportMethodRemoved( - JavaClass oldClass, + JavaType oldClass, Method oldMethod, - JavaClass currentClass) + JavaType currentClass) { if (!scopeSelector.isSelected(oldMethod)) { @@ -464,7 +463,7 @@ * Given a list of methods, report each one as being added. */ private void reportMethodsAdded( - JavaClass currentClass, + JavaType currentClass, List currentMethods) { for (Iterator i = currentMethods.iterator(); i.hasNext();) @@ -477,7 +476,7 @@ /** * Report that a method has been added to a class. */ - private void reportMethodAdded(JavaClass newClass, Method newMethod) + private void reportMethodAdded(JavaType newClass, Method newMethod) { if (!scopeSelector.isSelected(newMethod)) { @@ -528,7 +527,7 @@ /** * Builds a map from a method name to a List of methods. */ - private Map buildNameToMethodMap(JavaClass clazz) + private Map buildNameToMethodMap(JavaType clazz) { Method[] methods = clazz.getMethods(); Map retVal = new HashMap(); @@ -548,7 +547,7 @@ return retVal; } - private void check(JavaClass compatBaseline, Method baselineMethod, Method currentMethod) + private void check(JavaType compatBaseline, Method baselineMethod, Method currentMethod) { if (!scopeSelector.isSelected(baselineMethod) && !scopeSelector.isSelected(currentMethod)) { @@ -563,10 +562,10 @@ checkFinal(compatBaseline, baselineMethod, currentMethod); } - private void checkParameterTypes(JavaClass compatBaseline, Method baselineMethod, Method currentMethod) + private void checkParameterTypes(JavaType compatBaseline, Method baselineMethod, Method currentMethod) { - Type[] bArgs = baselineMethod.getArgumentTypes(); - Type[] cArgs = currentMethod.getArgumentTypes(); + JavaType[] bArgs = baselineMethod.getArgumentTypes(); + JavaType[] cArgs = currentMethod.getArgumentTypes(); if (bArgs.length != cArgs.length) { @@ -579,10 +578,10 @@ //System.out.println("baselineMethod = " + getMethodId(compatBaseline, baselineMethod)); for (int i = 0; i < bArgs.length; i++) { - Type bArg = bArgs[i]; - Type cArg = cArgs[i]; + JavaType bArg = bArgs[i]; + JavaType cArg = cArgs[i]; - if (bArg.toString().equals(cArg.toString())) + if (bArg.getName().equals(cArg.getName())) { continue; } @@ -599,10 +598,10 @@ } } - private void checkReturnType(JavaClass compatBaseline, Method baselineMethod, Method currentMethod) + private void checkReturnType(JavaType compatBaseline, Method baselineMethod, Method currentMethod) { - Type bReturnType = baselineMethod.getReturnType(); - Type cReturnType = currentMethod.getReturnType(); + JavaType bReturnType = baselineMethod.getReturnType(); + JavaType cReturnType = currentMethod.getReturnType(); // TODO: Check assignability. If the new return type is // assignable to the old type, then the code is source-code @@ -617,18 +616,18 @@ } private void checkDeclaredExceptions( - JavaClass compatBaseline, + JavaType compatBaseline, Method baselineMethod, Method currentMethod) { // TODO } private void checkDeprecated( - JavaClass compatBaseline, + JavaType compatBaseline, Method baselineMethod, Method currentMethod) { - boolean bIsDeprecated = isDeprecated(baselineMethod); - boolean cIsDeprecated = isDeprecated(currentMethod); + boolean bIsDeprecated = baselineMethod.isDeprecated(); + boolean cIsDeprecated = currentMethod.isDeprecated(); if (bIsDeprecated && !cIsDeprecated) { @@ -646,10 +645,10 @@ * Report changes in the declared accessibility of a method * (public/protected/etc). */ - private void checkVisibility(JavaClass compatBaseline, Method baselineMethod, Method currentMethod) + private void checkVisibility(JavaType compatBaseline, Method baselineMethod, Method currentMethod) { - ScopeSelector.Scope bScope = ScopeSelector.getScope(baselineMethod); - ScopeSelector.Scope cScope = ScopeSelector.getScope(currentMethod); + Scope bScope = baselineMethod.getEffectiveScope(); + Scope cScope = currentMethod.getEffectiveScope(); if (cScope.isLessVisibleThan(bScope)) { @@ -667,7 +666,7 @@ } private void checkFinal( - JavaClass compatBaseline, + JavaType compatBaseline, Method baselineMethod, Method currentMethod) { boolean bIsFinal = baselineMethod.isFinal(); @@ -692,11 +691,11 @@ * @param method the method to identify. * @return a human readable id, for example "public void print(java.lang.String)" */ - private String getMethodId(JavaClass clazz, Method method) + private String getMethodId(JavaType clazz, Method method) { StringBuffer buf = new StringBuffer(); - final String scopeDecl = ScopeSelector.getScopeDecl(method); + final String scopeDecl = method.getDeclaredScope().getDecl(); if (scopeDecl.length() > 0) { buf.append(scopeDecl); @@ -706,7 +705,7 @@ String name = method.getName(); if ("<init>".equals(name)) { - final String className = clazz.getClassName(); + final String className = clazz.getName(); int idx = className.lastIndexOf('.'); name = className.substring(idx + 1); } @@ -724,36 +723,23 @@ private void appendHumanReadableArgTypeList(Method method, StringBuffer buf) { - Type[] argTypes = method.getArgumentTypes(); + JavaType[] argTypes = method.getArgumentTypes(); String argSeparator = ""; for (int i = 0; i < argTypes.length; i++) { buf.append(argSeparator); - buf.append(argTypes[i].toString()); + buf.append(argTypes[i].getName()); argSeparator = ", "; } } - private void fireDiff(Message msg, Severity severity, JavaClass clazz, Method method, String[] args) + private void fireDiff(Message msg, Severity severity, JavaType clazz, Method method, String[] args) { - final String className = clazz.getClassName(); + final String className = clazz.getName(); final ApiDifference diff = new ApiDifference( msg, severity, className, getMethodId(clazz, method), null, args); getApiDiffDispatcher().fireDiff(diff); } - private boolean isDeprecated(Method method) - { - Attribute[] attrs = method.getAttributes(); - for (int i = 0; i < attrs.length; ++i) - { - if (attrs[i] instanceof org.apache.bcel.classfile.Deprecated) - { - return true; - } - } - - return false; - } } Index: InterfaceSetCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/InterfaceSetCheck.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- InterfaceSetCheck.java 3 Aug 2005 17:16:31 -0000 1.6 +++ InterfaceSetCheck.java 26 Aug 2005 05:35:52 -0000 1.7 @@ -28,8 +28,8 @@ import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; import net.sf.clirr.core.internal.CoIterator; -import net.sf.clirr.core.internal.JavaClassNameComparator; -import org.apache.bcel.classfile.JavaClass; +import net.sf.clirr.core.internal.NameComparator; +import net.sf.clirr.core.spi.JavaType; /** * Detects changes in the set of interfaces implemented by a class. @@ -53,30 +53,30 @@ } /** {@inheritDoc} */ - public boolean check(JavaClass compatBaseline, JavaClass currentVersion) + public boolean check(JavaType compatBaseline, JavaType currentVersion) { - JavaClass[] compatInterfaces = compatBaseline.getAllInterfaces(); - JavaClass[] currentInterfaces = currentVersion.getAllInterfaces(); + JavaType[] compatInterfaces = compatBaseline.getAllInterfaces(); + JavaType[] currentInterfaces = currentVersion.getAllInterfaces(); // Note: getAllInterfaces might return multiple array entries with the same // interface, so we need to use sets to remove duplicates... Set compat = createClassSet(compatInterfaces); Set current = createClassSet(currentInterfaces); - final String className = compatBaseline.getClassName(); + final String className = compatBaseline.getName(); CoIterator iter = new CoIterator( - JavaClassNameComparator.COMPARATOR, compat, current); + new NameComparator(), compat, current); while (iter.hasNext()) { iter.next(); - JavaClass compatInterface = (JavaClass) iter.getLeft(); - JavaClass currentInterface = (JavaClass) iter.getRight(); + JavaType compatInterface = (JavaType) iter.getLeft(); + JavaType currentInterface = (JavaType) iter.getRight(); - if (compatInterface != null && className.equals(compatInterface.getClassName()) - || currentInterface != null && className.equals(currentInterface.getClassName())) + if (compatInterface != null && className.equals(compatInterface.getName()) + || currentInterface != null && className.equals(currentInterface.getName())) { // This occurs because an interface has itself in the set of all interfaces. // We can't just let the test below handle this case because that won't @@ -96,14 +96,14 @@ // a throwable. However this is fairly low probability.. log(MSG_IFACE_ADDED, Severity.INFO, className, null, null, - new String[] {currentInterface.getClassName()}); + new String[] {currentInterface.getName()}); } else if (currentInterface == null) { log(MSG_IFACE_REMOVED, getSeverity(compatBaseline, Severity.ERROR), className, null, null, - new String[] {compatInterface.getClassName()}); + new String[] {compatInterface.getName()}); } } @@ -111,16 +111,16 @@ } /** - * Creates a Set of JavaClass objects. + * Creates a Set of JavaType objects. * @param classes the classes to include in the set, might contain duplicates - * @return Set<JavaClass> + * @return Set<JavaType> */ - private Set createClassSet(JavaClass[] classes) + private Set createClassSet(JavaType[] classes) { - // JavaClass does not define equals(), so we use a Set implementation + // JavaType does not specify the semantics of equals(), so we use a Set implementation // that determines equality by invoking a Comparator instead of calling equals() - Set current = new TreeSet(JavaClassNameComparator.COMPARATOR); + Set current = new TreeSet(new NameComparator()); for (int i = 0; i < classes.length; i++) { current.add(classes[i]); Index: ClassModifierCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/ClassModifierCheck.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ClassModifierCheck.java 3 Aug 2005 17:16:28 -0000 1.4 +++ ClassModifierCheck.java 26 Aug 2005 05:35:52 -0000 1.5 @@ -24,11 +24,9 @@ import net.sf.clirr.core.internal.AbstractDiffReporter; import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; -import net.sf.clirr.core.CheckerException; -import net.sf.clirr.core.ScopeSelector; - -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.classfile.Method; +import net.sf.clirr.core.spi.JavaType; +import net.sf.clirr.core.spi.Method; +import net.sf.clirr.core.spi.Scope; /** * Detects changes in class modifiers (abstract, final). @@ -56,24 +54,15 @@ } /** {@inheritDoc} */ - public boolean check(JavaClass compatBaseLine, JavaClass currentVersion) + public boolean check(JavaType compatBaseLine, JavaType currentVersion) { - final String className = compatBaseLine.getClassName(); + final String className = compatBaseLine.getName(); - try - { - ScopeSelector.Scope currentScope = ScopeSelector.getClassScope(currentVersion); - if (currentScope == ScopeSelector.SCOPE_PRIVATE) - { - // for private classes, we don't care if they are now final, - // or now abstract, or now an interface. - return true; - } - } - catch (CheckerException ex) + Scope currentScope = currentVersion.getEffectiveScope(); + if (currentScope.isLessVisibleThan(Scope.PACKAGE)) { - log(MSG_MODIFIER_UNABLE_TO_DETERMINE_CLASS_SCOPE, - Severity.ERROR, className, null, null, null); + // for private classes, we don't care if they are now final, + // or now abstract, or now an interface. return true; } @@ -126,7 +115,7 @@ * classes we should not emit errors when a final modifier is * introduced. */ - private boolean isEffectivelyFinal(JavaClass clazz) + private boolean isEffectivelyFinal(JavaType clazz) { if (clazz.isFinal()) { @@ -142,7 +131,7 @@ final String methodName = method.getName(); if (methodName.equals("<init>")) { - if (method.isPublic() || method.isProtected()) + if (method.getEffectiveScope().isMoreVisibleThan(Scope.PACKAGE)) { return false; } Index: ClassHierarchyCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/ClassHierarchyCheck.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ClassHierarchyCheck.java 3 Aug 2005 17:16:27 -0000 1.4 +++ ClassHierarchyCheck.java 26 Aug 2005 05:35:52 -0000 1.5 @@ -25,8 +25,8 @@ import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; import net.sf.clirr.core.internal.CoIterator; -import net.sf.clirr.core.internal.JavaClassNameComparator; -import org.apache.bcel.classfile.JavaClass; +import net.sf.clirr.core.internal.NameComparator; +import net.sf.clirr.core.spi.JavaType; /** * Detects changes in the set of superclasses. @@ -48,30 +48,30 @@ } /** {@inheritDoc} */ - public boolean check(JavaClass compatBaseline, JavaClass currentVersion) + public boolean check(JavaType compatBaseline, JavaType currentVersion) { - JavaClass[] compatSupers = compatBaseline.getSuperClasses(); - JavaClass[] currentSupers = currentVersion.getSuperClasses(); + JavaType[] compatSupers = compatBaseline.getSuperClasses(); + JavaType[] currentSupers = currentVersion.getSuperClasses(); boolean isThrowable = false; for (int i = 0; i < compatSupers.length; i++) { - JavaClass javaClass = compatSupers[i]; - if ("java.lang.Throwable".equals(javaClass.getClassName())) + JavaType javaClass = compatSupers[i]; + if ("java.lang.Throwable".equals(javaClass.getName())) { isThrowable = true; } } - final String className = compatBaseline.getClassName(); + final String className = compatBaseline.getName(); - CoIterator iter = new CoIterator(JavaClassNameComparator.COMPARATOR, compatSupers, currentSupers); + CoIterator iter = new CoIterator(new NameComparator(), compatSupers, currentSupers); while (iter.hasNext()) { iter.next(); - JavaClass baselineSuper = (JavaClass) iter.getLeft(); - JavaClass currentSuper = (JavaClass) iter.getRight(); + JavaType baselineSuper = (JavaType) iter.getLeft(); + JavaType currentSuper = (JavaType) iter.getRight(); if (baselineSuper == null) { @@ -90,13 +90,13 @@ log(MSG_ADDED_CLASS_TO_SUPERCLASSES, getSeverity(compatBaseline, severity), className, null, null, - new String[] {currentSuper.getClassName()}); + new String[] {currentSuper.getName()}); } else if (currentSuper == null) { log(MSG_REMOVED_CLASS_FROM_SUPERCLASSES, getSeverity(compatBaseline, Severity.ERROR), className, null, null, - new String[] {baselineSuper.getClassName()}); + new String[] {baselineSuper.getName()}); } } Index: GenderChangeCheck.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/checks/GenderChangeCheck.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- GenderChangeCheck.java 3 Aug 2005 17:16:28 -0000 1.5 +++ GenderChangeCheck.java 26 Aug 2005 05:35:52 -0000 1.6 @@ -24,7 +24,7 @@ import net.sf.clirr.core.internal.AbstractDiffReporter; import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; -import org.apache.bcel.classfile.JavaClass; +import net.sf.clirr.core.spi.JavaType; /** * Detects gender changes (a class became an interface or vice versa). @@ -49,19 +49,19 @@ /** {@inheritDoc} */ - public boolean check(JavaClass baseLine, JavaClass current) + public boolean check(JavaType baseLine, JavaType current) { - if (baseLine.isClass() && current.isInterface()) + if (!baseLine.isInterface() && current.isInterface()) { log(MSG_GENDER_CLASS_TO_INTERFACE, getSeverity(baseLine, Severity.ERROR), - baseLine.getClassName(), null, null, null); + baseLine.getName(), null, null, null); } - else if (baseLine.isInterface() && current.isClass()) + else if (baseLine.isInterface() && !current.isInterface()) { log(MSG_GENDER_INTERFACE_TO_CLASS, getSeverity(baseLine, Severity.ERROR), - baseLine.getClassName(), null, null, null); + baseLine.getName(), null, null, null); } return true; |
From: <lk...@us...> - 2005-08-26 05:36:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/src/java/net/sf/clirr/core Modified Files: Checker.java CheckerException.java ScopeSelector.java Log Message: moved clirr implementation to new SPI infrastructure Index: Checker.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/Checker.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Checker.java 7 Aug 2005 13:54:03 -0000 1.7 +++ Checker.java 26 Aug 2005 05:35:53 -0000 1.8 @@ -32,6 +32,7 @@ import java.net.MalformedURLException; import java.net.URLClassLoader; +import net.sf.clirr.core.internal.bcel.BcelJavaType; import net.sf.clirr.core.internal.checks.ClassHierarchyCheck; import net.sf.clirr.core.internal.checks.ClassScopeCheck; import net.sf.clirr.core.internal.checks.ClassModifierCheck; @@ -42,12 +43,13 @@ import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.ClassChangeCheck; import net.sf.clirr.core.internal.CoIterator; -import net.sf.clirr.core.internal.JavaClassNameComparator; import net.sf.clirr.core.internal.ExceptionUtil; +import net.sf.clirr.core.internal.NameComparator; +import net.sf.clirr.core.spi.JavaType; +import net.sf.clirr.core.spi.Scope; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.ClassParser; -import org.apache.bcel.util.ClassSet; import org.apache.bcel.util.Repository; import org.apache.bcel.util.ClassLoaderRepository; @@ -169,10 +171,10 @@ classSelector = new ClassSelector(ClassSelector.MODE_UNLESS); } - final ClassSet origClasses = + final JavaType[] origClasses = createClassSet(origJars, origThirdPartyLoader, classSelector); - final ClassSet newClasses = + final JavaType[] newClasses = createClassSet(newJars, newThirdPartyLoader, classSelector); reportDiffs(origClasses, newClasses); @@ -190,7 +192,7 @@ * old and new jars are to be compared. This parameter may be null, in * which case all classes in the old and new jars are compared. */ - private static ClassSet createClassSet( + private static JavaType[] createClassSet( File[] jarFiles, ClassLoader thirdPartyClasses, ClassFilter classSelector) throws CheckerException { @@ -204,7 +206,7 @@ Repository repository = new ClassLoaderRepository(classLoader); - ClassSet ret = new ClassSet(); + List selected = new ArrayList(); for (int i = 0; i < jarFiles.length; i++) { @@ -228,13 +230,15 @@ JavaClass clazz = extractClass(zipEntry, zip, repository); if (classSelector.isSelected(clazz)) { - ret.add(clazz); + selected.add(new BcelJavaType(clazz)); repository.storeClass(clazz); } } } } + JavaType[] ret = new JavaType[selected.size()]; + selected.toArray(ret); return ret; } @@ -312,7 +316,7 @@ * compatibility with compatibilityBaseline */ private void reportDiffs( - ClassSet compatibilityBaseline, ClassSet currentVersion) + JavaType[] compatibilityBaseline, JavaType[] currentVersion) throws CheckerException { fireStart(); @@ -321,29 +325,26 @@ } private void runClassChecks( - ClassSet compatBaseline, ClassSet currentVersion) + JavaType[] compat, JavaType[] current) throws CheckerException { - JavaClass[] compat = compatBaseline.toArray(); - JavaClass[] current = currentVersion.toArray(); - CoIterator iter = new CoIterator( - JavaClassNameComparator.COMPARATOR, compat, current); + new NameComparator(), compat, current); while (iter.hasNext()) { iter.next(); - JavaClass compatBaselineClass = (JavaClass) iter.getLeft(); - JavaClass currentClass = (JavaClass) iter.getRight(); + JavaType compatBaselineClass = (JavaType) iter.getLeft(); + JavaType currentClass = (JavaType) iter.getRight(); if (compatBaselineClass == null) { - if (!scopeSelector.isSelected(ScopeSelector.getClassScope(currentClass))) + if (!scopeSelector.isSelected(currentClass.getEffectiveScope())) { continue; } - final String className = currentClass.getClassName(); + final String className = currentClass.getName(); final ApiDifference diff = new ApiDifference( MSG_CLASS_ADDED, Severity.INFO, className, @@ -352,14 +353,14 @@ } else if (currentClass == null) { - final ScopeSelector.Scope classScope = ScopeSelector.getClassScope(compatBaselineClass); + final Scope classScope = compatBaselineClass.getEffectiveScope(); if (!scopeSelector.isSelected(classScope)) { continue; } - final String className = compatBaselineClass.getClassName(); + final String className = compatBaselineClass.getName(); final Severity severity = classScope.isLessVisibleThan( - ScopeSelector.SCOPE_PROTECTED) ? Severity.INFO : Severity.ERROR; + Scope.PROTECTED) ? Severity.INFO : Severity.ERROR; final ApiDifference diff = new ApiDifference( MSG_CLASS_REMOVED, severity, className, Index: CheckerException.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/CheckerException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CheckerException.java 3 Aug 2005 17:16:10 -0000 1.3 +++ CheckerException.java 26 Aug 2005 05:35:53 -0000 1.4 @@ -30,7 +30,7 @@ * Unchecked exceptions are used for errors that are due to bugs within * clirr code (assertion-violation type problems). */ -public class CheckerException extends Exception +public class CheckerException extends RuntimeException // TODO: revert this back to Exception to match the class doc above { public CheckerException(String msg) { Index: ScopeSelector.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/ScopeSelector.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ScopeSelector.java 3 Aug 2005 17:16:13 -0000 1.5 +++ ScopeSelector.java 26 Aug 2005 05:35:53 -0000 1.6 @@ -18,16 +18,8 @@ ////////////////////////////////////////////////////////////////////////////// package net.sf.clirr.core; -import org.apache.bcel.Constants; -import org.apache.bcel.classfile.AccessFlags; -import org.apache.bcel.classfile.Attribute; -import org.apache.bcel.classfile.ConstantClass; -import org.apache.bcel.classfile.ConstantPool; -import org.apache.bcel.classfile.ConstantUtf8; -import org.apache.bcel.classfile.InnerClass; -import org.apache.bcel.classfile.InnerClasses; -import org.apache.bcel.classfile.JavaClass; -import org.apache.bcel.util.Repository; +import net.sf.clirr.core.spi.Scope; +import net.sf.clirr.core.spi.Scoped; /** * Selects zero or more java scope values (public, protected, package, @@ -42,62 +34,7 @@ */ public final class ScopeSelector { - /** - * Represents an "accessibility" level for a java class, field or method. - * <p> - * Change of access rights from lower to higher visibility rating is a - * binary-compatible change. Change of access rights from higher to - * lower is a binary-incompatible change. - * <p> - * Public > Protected > Package > Private - */ - public static final class Scope - { - private int vis; - private String desc; - private String decl; - - private Scope(int vis, String desc, String decl) - { - this.vis = vis; - this.desc = desc; - this.decl = decl; - } - - public boolean isMoreVisibleThan(Scope v) - { - return this.vis > v.vis; - } - - public boolean isLessVisibleThan(Scope v) - { - return this.vis < v.vis; - } - - public String getDesc() - { - return desc; - } - - public String getDecl() - { - return decl; - } - } - - /** Object representing private scoped objects. */ - public static final Scope SCOPE_PRIVATE = new Scope(0, "private", "private"); - - /** Object representing package scoped objects. */ - public static final Scope SCOPE_PACKAGE = new Scope(1, "package", ""); - - /** Object representing protected scoped objects. */ - public static final Scope SCOPE_PROTECTED = new Scope(2, "protected", "protected"); - - /** Object representing public scoped objects. */ - public static final Scope SCOPE_PUBLIC = new Scope(3, "public", "public"); - - private Scope scope = SCOPE_PROTECTED; + private Scope scope = Scope.PROTECTED; /** * Construct an instance which selects public and protected objects and @@ -158,9 +95,9 @@ * @param object is the object whose scope is to be checked. * @return true if the object is selected. */ - public boolean isSelected(AccessFlags object) + public boolean isSelected(Scoped scoped) { - return !getScope(object).isLessVisibleThan(scope); + return !scoped.getEffectiveScope().isLessVisibleThan(scope); } /** @@ -175,205 +112,5 @@ return !scope.isLessVisibleThan(this.scope); } - /** - * Given a BCEL object, return the string which would be used in java - * source code to declare that object's scope. <p> - * <p> - * Note that BCEL classes Field and Method inherit from the AccessFlags - * base class and so are valid parameters to this method. - * <p> - * Note that despite JavaClass objects extending AccessFlags, the - * methods which determine the accessibility of a JavaClass fail - * miserably (bad bcel design) for nested classes. Therefore this - * method <i>must not</i> be passed a JavaClass object as a parameter. - * If this is done, a RuntimeException will be thrown to indicate a - * programmer error. - */ - public static String getScopeDecl(AccessFlags object) - { - return getScope(object).getDecl(); - } - - /** - * Given an integer representing an object's access flags, return the - * string which would be used in java source code to declare that object's - * scope. - * <p> - * Note that this method gives the wrong results for JavaClass objects - * which are nested classes. Use getClassScope(jclass).getDecl() instead. - */ - public static String getScopeDecl(int accessFlags) - { - return getScope(accessFlags).getDecl(); - } - - /** - * Given a BCEL object, return a string indicating whether the object is - * public/protected/private/package scope. This is similar to - * getScopeName, except for package-scope objects where this method - * returns the string "package". - * <p> - * Note that BCEL classes Field and Method inherit from the AccessFlags - * base class and so are valid parameters to this method. - * <p> - * Note that despite JavaClass objects extending AccessFlags, the - * methods which determine the accessibility of a JavaClass fail - * miserably (bad bcel design) for nested classes. Therefore this - * method <i>must not</i> be passed a JavaClass object as a parameter. - * If this is done, a RuntimeException will be thrown to indicate a - * programmer error. - */ - public static String getScopeDesc(AccessFlags object) - { - return getScope(object).getDesc(); - } - - /** - * Given an integer representing the object's access flags, return a string - * indicating whether the object is public/protected/private/package scope. - * <p> - * This is similar to getScopeName, except for package-scope objects where - * this method returns the string "package". - * <p> - * Note that this method gives the wrong results for JavaClass objects - * which are nested classes. Use getClassScope(jclass).getDesc() instead. - */ - public static String getScopeDesc(int accessFlags) - { - return getScope(accessFlags).getDesc(); - } - - /** - * Get a Scope object representing the accessibility of the specified - * object. - * <p> - * Note that BCEL classes Field and Method inherit from the AccessFlags - * base class and so are valid parameters to this method. - * <p> - * Note that despite JavaClass objects extending AccessFlags, the - * methods which determine the accessibility of a JavaClass fail - * miserably (bad bcel design) for nested classes. Therefore this - * method <i>must not</i> be passed a JavaClass object as a parameter. - * If this is done, a RuntimeException will be thrown to indicate a - * programmer error. Use getClassScope instead. - */ - public static Scope getScope(AccessFlags object) - { - if (object instanceof JavaClass) - { - throw new RuntimeException( - "getScope called for JavaClass object. This is not permitted;" - + " use method getClassScope for JavaClass objects."); - - } - - return getScope(object.getAccessFlags()); - } - - /** - * Get a Scope object representing the accessibility of the specified - * object. - * <p> - * Note that this method gives the wrong results for JavaClass objects - * which are nested classes. Use getClassScope(jclass) instead. - */ - public static Scope getScope(int accessFlags) - { - if ((accessFlags & Constants.ACC_PUBLIC) > 0) - { - return SCOPE_PUBLIC; - } - - if ((accessFlags & Constants.ACC_PROTECTED) > 0) - { - return SCOPE_PROTECTED; - } - - if ((accessFlags & Constants.ACC_PRIVATE) > 0) - { - return SCOPE_PRIVATE; - } - - return SCOPE_PACKAGE; - } - - /** - * Java class files only ever contain scope specifiers of "public" or - * "package". For top-level classes, this is expected: it is not possible - * to have a top-level protected or private class. - * <p> - * However nested classes <i>can</i> be declared as protected or private. The - * way to tell the real scope of a nested class is to ignore the scope in - * the actual class file itself, and instead look in the "InnerClasses" - * attribute stored on the enclosing class. This is exactly what the java - * compiler does when compiling, and what the jvm does when verifying class - * linkage at runtime. - * <p> - * For a "top-level" class, this method just returns the access scope for - * the class itself. For nested classes, the enclosing class of the - * specified class is retrieved and its InnerClasses attribute checked to - * find the true scope for the specified class. - * <p> - * @throws CheckerException if the specified class is a nested class and - * the enclosing class could not be found, or if the supposedly enclosing - * class has no reference to the nested class. This exception is not - * expected to occur in practice, unless a truly screwed-up jar file is - * passed to clirr for inspection. - */ - public static Scope getClassScope(JavaClass jclass) throws CheckerException - { - int dollarPos = jclass.getClassName().lastIndexOf('$'); - if (dollarPos == -1) - { - // not a nested class - return getScope(jclass.getAccessFlags()); - } - - // ok this is a nested class - String jclassName = jclass.getClassName(); - String enclosingClassName = jclassName.substring(0, dollarPos); - Repository repo = jclass.getRepository(); - JavaClass enclosingClass = repo.findClass(enclosingClassName); - - if (enclosingClass == null) - { - throw new CheckerException( - "Unable to locate enclosing class " + enclosingClassName - + " for nested class " + jclassName); - } - - ConstantPool pool = enclosingClass.getConstantPool(); - Attribute[] attrs = enclosingClass.getAttributes(); - for (int i = 0; i < attrs.length; ++i) - { - if (attrs[i] instanceof InnerClasses) - { - InnerClasses ics = (InnerClasses) attrs[i]; - InnerClass[] icarray = ics.getInnerClasses(); - for (int j = 0; j < icarray.length; ++j) - { - // in the code below, instanceof checks should not be necessary - // before casting Constants because the classfile format ensures - // that instanceof would always be true - InnerClass ic = icarray[j]; - int classIndex = ic.getInnerClassIndex(); - ConstantClass constClass = (ConstantClass) pool.getConstant(classIndex); - int nameIndex = constClass.getNameIndex(); - ConstantUtf8 nameconst = (ConstantUtf8) pool.getConstant(nameIndex); - String classname = nameconst.getBytes().replace('/', '.'); - if (jclassName.equals(classname)) - { - return getScope(ic.getInnerAccessFlags()); - } - } - } - } - - // weird; no nested class info found - throw new CheckerException( - "Unable to find information in class " + enclosingClass.getClassName() - + " referring back to nested class " + jclassName); - - } } |
From: <lk...@us...> - 2005-08-26 05:36:01
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/cli In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/src/java/net/sf/clirr/cli Modified Files: Clirr.java Log Message: moved clirr implementation to new SPI infrastructure Index: Clirr.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/cli/Clirr.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Clirr.java 3 Aug 2005 17:16:09 -0000 1.4 +++ Clirr.java 26 Aug 2005 05:35:53 -0000 1.5 @@ -25,7 +25,8 @@ import net.sf.clirr.core.PlainDiffListener; import net.sf.clirr.core.XmlDiffListener; import net.sf.clirr.core.DiffListener; -import net.sf.clirr.core.ScopeSelector; +import net.sf.clirr.core.spi.Scope; + import org.apache.commons.cli.BasicParser; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; @@ -102,11 +103,11 @@ Checker checker = new Checker(); if (showAll) { - checker.getScopeSelector().setScope(ScopeSelector.SCOPE_PRIVATE); + checker.getScopeSelector().setScope(Scope.PRIVATE); } else if (showPkg) { - checker.getScopeSelector().setScope(ScopeSelector.SCOPE_PACKAGE); + checker.getScopeSelector().setScope(Scope.PACKAGE); } ClassSelector classSelector; |
From: <lk...@us...> - 2005-08-26 05:36:01
|
Update of /cvsroot/clirr/clirr/core/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/xdocs Modified Files: changes.xml Log Message: moved clirr implementation to new SPI infrastructure Index: changes.xml =================================================================== RCS file: /cvsroot/clirr/clirr/core/xdocs/changes.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- changes.xml 7 Aug 2005 13:54:03 -0000 1.8 +++ changes.xml 26 Aug 2005 05:35:53 -0000 1.9 @@ -7,6 +7,20 @@ </properties> <body> + <release version="0.6-dev" date="in CVS"> + <action dev="lkuehne" type="add"> + Clirr now provides a SPI to represent the java code structure, the checks + now work against this SPI. Clirr provides a SPI implementation that works + on jar files, but other implementations can be used as well. For example, + an IDE will typically already have an in-memory representation of the Java + sources, so a Clirr IDE plugin could use that (via an adapter) and would + not require a full compile before running Clirr. + </action> + <action dev="lkuehne" type="fix"> + Improved test coverage. + </action> + </release> + <release version="0.5" date="2005-08-07"> <action dev="lkuehne" type="fix"> Avoid false alarms when package visible classes are removed. |
From: <lk...@us...> - 2005-08-26 05:36:00
|
Update of /cvsroot/clirr/clirr/core/src/testinput/testlib-v1/testlib/scope In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/src/testinput/testlib-v1/testlib/scope Modified Files: ClassScopeChange.java Log Message: moved clirr implementation to new SPI infrastructure Index: ClassScopeChange.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/testinput/testlib-v1/testlib/scope/ClassScopeChange.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ClassScopeChange.java 2 Sep 2004 04:21:32 -0000 1.2 +++ ClassScopeChange.java 26 Aug 2005 05:35:53 -0000 1.3 @@ -14,6 +14,9 @@ // public class becomes private public static class A4 {} + // public class is removed + public static class A5 {} + // protected class is unchanged protected static class B1 {} @@ -37,6 +40,9 @@ // package class becomes private static class C4 {} + + // package class is removed + static class C5 {} // private class is unchanged private static class D1 {} |
Update of /cvsroot/clirr/clirr/core/src/test/net/sf/clirr/core/internal/checks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502/src/test/net/sf/clirr/core/internal/checks Modified Files: ClassScopeCheckTest.java TestDiffListener.java Added Files: ClassAddedRemovedTest.java Log Message: moved clirr implementation to new SPI infrastructure --- NEW FILE --- package net.sf.clirr.core.internal.checks; import java.net.URL; import java.net.URLClassLoader; import net.sf.clirr.core.Checker; import net.sf.clirr.core.CheckerFactory; import net.sf.clirr.core.Severity; import net.sf.clirr.core.internal.ClassChangeCheck; import net.sf.clirr.core.ClassFilter; public class ClassAddedRemovedTest extends AbstractCheckTestCase { public void testClassAddionOrRemovalIsReported() throws Exception { Checker checker = CheckerFactory.createChecker(null); TestDiffListener tld = new TestDiffListener(); checker.addDiffListener(tld); ClassFilter classSelector = createClassSelector(); checker.reportDiffs( getBaseLine(), getCurrent(), new URLClassLoader(new URL[]{}), new URLClassLoader(new URL[]{}), classSelector); ExpectedDiff[] expected = new ExpectedDiff[] { new ExpectedDiff("Class testlib.AddedClass added", Severity.INFO, "testlib.AddedClass", null, null), new ExpectedDiff("Class testlib.RemovedClass removed", Severity.ERROR, "testlib.RemovedClass", null, null), }; tld.checkExpected(expected); } protected ClassChangeCheck createCheck(TestDiffListener tdl) { // changes are reported directly by the Checker return null; } } Index: ClassScopeCheckTest.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/test/net/sf/clirr/core/internal/checks/ClassScopeCheckTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ClassScopeCheckTest.java 6 Mar 2005 17:01:35 -0000 1.3 +++ ClassScopeCheckTest.java 26 Aug 2005 05:35:53 -0000 1.4 @@ -7,6 +7,7 @@ import net.sf.clirr.core.ClassFilter; import net.sf.clirr.core.internal.checks.ClassScopeCheck; import net.sf.clirr.core.internal.checks.AbstractCheckTestCase; +import net.sf.clirr.core.spi.Scope; /** * Tests for the ClassScopeCheck test. @@ -40,7 +41,7 @@ protected ClassChangeCheck createCheck(TestDiffListener tdl) { - ScopeSelector scopeSelector = new ScopeSelector(ScopeSelector.SCOPE_PRIVATE); + ScopeSelector scopeSelector = new ScopeSelector(Scope.PRIVATE); return new ClassScopeCheck(tdl, scopeSelector); } Index: TestDiffListener.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/test/net/sf/clirr/core/internal/checks/TestDiffListener.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TestDiffListener.java 20 Jul 2004 07:53:23 -0000 1.4 +++ TestDiffListener.java 26 Aug 2005 05:35:53 -0000 1.5 @@ -7,10 +7,11 @@ import net.sf.clirr.core.internal.ApiDiffDispatcher; import net.sf.clirr.core.internal.checks.ExpectedDiff; import net.sf.clirr.core.ApiDifference; +import net.sf.clirr.core.DiffListener; import net.sf.clirr.core.MessageTranslator; import junit.framework.TestCase; -class TestDiffListener implements ApiDiffDispatcher +class TestDiffListener implements ApiDiffDispatcher, DiffListener { private MessageTranslator translator = new MessageTranslator(); @@ -95,4 +96,16 @@ TestCase.fail(buf.toString()); } } + + public void start() + { + } + + public void reportDiff(ApiDifference difference) { + diffs.add(difference); + } + + public void stop() + { + } } |
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/bcel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8230/src/java/net/sf/clirr/core/internal/bcel Added Files: BcelMethod.java BcelField.java BcelJavaType.java BcelScopeHelper.java Log Message: added bcel implementation for SPI --- NEW FILE --- package net.sf.clirr.core.internal.bcel; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.Type; import net.sf.clirr.core.spi.JavaType; import net.sf.clirr.core.spi.Scope; final class BcelMethod implements net.sf.clirr.core.spi.Method { private Method method; private JavaClass owningClass; public BcelMethod(JavaClass owningClass, Method method) { this.owningClass = owningClass; this.method = method; } public JavaType getReturnType() { return convertType(method.getReturnType()); } public String getName() { return method.getName(); } public boolean isFinal() { return method.isFinal(); } public boolean isStatic() { return method.isStatic(); } public boolean isAbstract() { return method.isAbstract(); } public boolean isDeprecated() { Attribute[] attrs = method.getAttributes(); for (int i = 0; i < attrs.length; ++i) { if (attrs[i] instanceof org.apache.bcel.classfile.Deprecated) { return true; } } return false; } public Scope getDeclaredScope() { return BcelScopeHelper.getScope(method.getAccessFlags()); } public Scope getEffectiveScope() { // TODO: real impl return getDeclaredScope(); } public JavaType[] getArgumentTypes() { final Type[] types = method.getArgumentTypes(); return convertTypes(types); } private JavaType convertType(Type bcelType) { return new BcelJavaType(bcelType, owningClass.getRepository()); } /** * @param types * @return */ private JavaType[] convertTypes(final Type[] types) { JavaType[] retval = new JavaType[types.length]; for (int i = 0; i < retval.length; i++) { retval[i] = convertType(types[i]); } return retval; } } --- NEW FILE --- package net.sf.clirr.core.internal.bcel; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; import net.sf.clirr.core.spi.JavaType; import net.sf.clirr.core.spi.Scope; final class BcelField implements net.sf.clirr.core.spi.Field { private final Field field; private final JavaClass owningClass; BcelField(JavaClass owningClass, Field field) { this.owningClass = owningClass; this.field = field; } public String getName() { return field.getName(); } public JavaType getType() { return new BcelJavaType(field.getType(), owningClass.getRepository()); } public boolean isFinal() { return field.isFinal(); } public boolean isStatic() { return field.isStatic(); } public boolean isDeprecated() { Attribute[] attrs = field.getAttributes(); for (int i = 0; i < attrs.length; ++i) { if (attrs[i] instanceof org.apache.bcel.classfile.Deprecated) { return true; } } return false; } public Object getConstantValue() { return field.getConstantValue(); } public Scope getDeclaredScope() { return BcelScopeHelper.getScope(field.getAccessFlags()); } public Scope getEffectiveScope() { return getDeclaredScope(); // FIXME } public String toString() { return field.toString(); } } --- NEW FILE --- package net.sf.clirr.core.internal.bcel; import net.sf.clirr.core.spi.Field; import net.sf.clirr.core.spi.JavaType; import net.sf.clirr.core.spi.Method; import net.sf.clirr.core.spi.Scope; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.generic.ObjectType; import org.apache.bcel.generic.Type; import org.apache.bcel.util.Repository; /** * */ public final class BcelJavaType implements JavaType { private Type type; private JavaClass clazz; private Repository repository; public BcelJavaType(Type bcelType, Repository repository) { this.type = bcelType; this.repository = repository; this.clazz = findJavaClass(type); } public BcelJavaType(JavaClass clazz) { this.type = null; // TODO: how can I convert a JavaClass to the corresponding Type? this.repository = clazz.getRepository(); this.clazz = clazz; } public String getName() { if (clazz != null) { return clazz.getClassName(); } else { return type.toString(); } } public JavaType getContainingClass() { // TODO: move code from ScopeHelper here return null; } private JavaClass findJavaClass(Type type) { if (!(type instanceof ObjectType)) { return null; } ObjectType ot = (ObjectType) type; return repository.findClass(ot.getClassName()); } public JavaType[] getSuperClasses() { if (clazz == null) { return new JavaType[0]; } final JavaClass[] superClasses = clazz.getSuperClasses(); return convertToJavaTypeArray(superClasses); } public JavaType[] getAllInterfaces() { if (clazz == null) { return new JavaType[0]; } final JavaClass[] interfaces = clazz.getAllInterfaces(); return convertToJavaTypeArray(interfaces); } public JavaType[] getInnerClasses() { return new JavaType[0]; } public Method[] getMethods() { if (clazz == null) { return new Method[0]; } final org.apache.bcel.classfile.Method[] methods = clazz.getMethods(); Method[] ret = new Method[methods.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new BcelMethod(clazz, methods[i]); } return ret; } public Field[] getFields() { if (clazz == null) { return new Field[0]; } final org.apache.bcel.classfile.Field[] fields = clazz.getFields(); Field[] ret = new Field[fields.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new BcelField(clazz, fields[i]); } return ret; } public boolean isPrimitive() { return clazz == null; } public boolean isArray() { return false; } public boolean isFinal() { if (clazz == null) { return false; } return clazz.isFinal(); } public boolean isAbstract() { if (clazz == null) { return false; } return clazz.isAbstract(); } public boolean isInterface() { return clazz.isInterface(); } public Scope getDeclaredScope() { return BcelScopeHelper.getClassScope(clazz); } public Scope getEffectiveScope() { return getDeclaredScope(); // FIXME } public String toString() { return getName(); } /** * @param bcelClasses * @return */ private JavaType[] convertToJavaTypeArray(final JavaClass[] bcelClasses) { JavaType[] ret = new JavaType[bcelClasses.length]; for (int i = 0; i < ret.length; i++) { ret[i] = new BcelJavaType(bcelClasses[i]); } return ret; } } --- NEW FILE --- package net.sf.clirr.core.internal.bcel; import net.sf.clirr.core.CheckerException; import net.sf.clirr.core.spi.Scope; import org.apache.bcel.Constants; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ConstantUtf8; import org.apache.bcel.classfile.InnerClass; import org.apache.bcel.classfile.InnerClasses; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.util.Repository; final class BcelScopeHelper { /** * * */ private BcelScopeHelper() { } /** * Get a Scope object representing the accessibility of the specified * object. * <p> * Note that this method gives the wrong results for JavaClass objects * which are nested classes. Use getClassScope(jclass) instead. */ public static Scope getScope(int accessFlags) { if ((accessFlags & Constants.ACC_PUBLIC) > 0) { return Scope.PUBLIC; } if ((accessFlags & Constants.ACC_PROTECTED) > 0) { return Scope.PROTECTED; } if ((accessFlags & Constants.ACC_PRIVATE) > 0) { return Scope.PRIVATE; } return Scope.PACKAGE; } /** * Java class files only ever contain scope specifiers of "public" or * "package". For top-level classes, this is expected: it is not possible * to have a top-level protected or private class. * <p> * However nested classes <i>can</i> be declared as protected or private. The * way to tell the real scope of a nested class is to ignore the scope in * the actual class file itself, and instead look in the "InnerClasses" * attribute stored on the enclosing class. This is exactly what the java * compiler does when compiling, and what the jvm does when verifying class * linkage at runtime. * <p> * For a "top-level" class, this method just returns the access scope for * the class itself. For nested classes, the enclosing class of the * specified class is retrieved and its InnerClasses attribute checked to * find the true scope for the specified class. * <p> * @throws CheckerException if the specified class is a nested class and * the enclosing class could not be found, or if the supposedly enclosing * class has no reference to the nested class. This exception is not * expected to occur in practice, unless a truly screwed-up jar file is * passed to clirr for inspection. */ public static Scope getClassScope(JavaClass jclass) throws CheckerException { int dollarPos = jclass.getClassName().lastIndexOf('$'); if (dollarPos == -1) { // not a nested class return getScope(jclass.getAccessFlags()); } // ok this is a nested class String jclassName = jclass.getClassName(); String enclosingClassName = jclassName.substring(0, dollarPos); Repository repo = jclass.getRepository(); JavaClass enclosingClass = repo.findClass(enclosingClassName); if (enclosingClass == null) { throw new CheckerException( "Unable to locate enclosing class " + enclosingClassName + " for nested class " + jclassName); } ConstantPool pool = enclosingClass.getConstantPool(); Attribute[] attrs = enclosingClass.getAttributes(); for (int i = 0; i < attrs.length; ++i) { if (attrs[i] instanceof InnerClasses) { InnerClasses ics = (InnerClasses) attrs[i]; InnerClass[] icarray = ics.getInnerClasses(); for (int j = 0; j < icarray.length; ++j) { // in the code below, instanceof checks should not be necessary // before casting Constants because the classfile format ensures // that instanceof would always be true InnerClass ic = icarray[j]; int classIndex = ic.getInnerClassIndex(); ConstantClass constClass = (ConstantClass) pool.getConstant(classIndex); int nameIndex = constClass.getNameIndex(); ConstantUtf8 nameconst = (ConstantUtf8) pool.getConstant(nameIndex); String classname = nameconst.getBytes().replace('/', '.'); if (jclassName.equals(classname)) { return getScope(ic.getInnerAccessFlags()); } } } } // weird; no nested class info found throw new CheckerException( "Unable to find information in class " + enclosingClass.getClassName() + " referring back to nested class " + jclassName); } } |
From: <lk...@us...> - 2005-08-26 05:34:05
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/bcel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8198/src/java/net/sf/clirr/core/internal/bcel Log Message: Directory /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/bcel added to the repository |
From: <lk...@us...> - 2005-08-26 05:30:51
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7837/src/java/net/sf/clirr/core/internal Added Files: NameComparator.java Log Message: added NameComparator --- NEW FILE --- package net.sf.clirr.core.internal; import java.util.Comparator; import net.sf.clirr.core.spi.Named; /** * Compares {@link Named named entities} by their name. * * @author Simon Kitching * @author lkuehne */ public final class NameComparator implements Comparator { public NameComparator() { } public int compare(Object o1, Object o2) { Named f1 = (Named) o1; Named f2 = (Named) o2; final String name1 = f1.getName(); final String name2 = f2.getName(); return name1.compareTo(name2); } } |
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/spi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7638/src/java/net/sf/clirr/core/spi Added Files: Named.java Scope.java Method.java Scoped.java Field.java JavaType.java package.html Log Message: added spi package --- NEW FILE --- package net.sf.clirr.core.spi; /** * A named entity in the Java programming language. * * @author lkuehne */ public interface Named { /** * Returns the name of this object. */ String getName(); } --- NEW FILE --- package net.sf.clirr.core.spi; /** * Enumeration type that represents an "accessibility" level for * a java class, field or method. * <p> * Change of access rights from lower to higher visibility rating is a * binary-compatible change. Change of access rights from higher to * lower is a binary-incompatible change. * <p> * Public > Protected > Package > Private * * @author Simon Kitching */ public final class Scope { private int vis; private String desc; private String decl; /** Object representing private scoped objects. */ public static final Scope PRIVATE = new Scope(0, "private", "private"); /** Object representing package scoped objects. */ public static final Scope PACKAGE = new Scope(1, "package", ""); /** Object representing protected scoped objects. */ public static final Scope PROTECTED = new Scope(2, "protected", "protected"); /** Object representing public scoped objects. */ public static final Scope PUBLIC = new Scope(3, "public", "public"); private Scope(int vis, String desc, String decl) { this.vis = vis; this.desc = desc; this.decl = decl; } public boolean isMoreVisibleThan(Scope v) { return this.vis > v.vis; } public boolean isLessVisibleThan(Scope v) { return this.vis < v.vis; } public String getDesc() { return desc; } /** the Java visibility modifier. **/ public String getDecl() { return decl; } } --- NEW FILE --- package net.sf.clirr.core.spi; /** * Describes a Java method. */ public interface Method extends Named, Scoped { /** * * @return the return type of this method, or null if the method return type is <code>void</code> */ JavaType getReturnType(); /** * * @return the argument types of this method, never null. */ JavaType[] getArgumentTypes(); // JavaType[] getDeclaredExceptions(); boolean isFinal(); boolean isStatic(); boolean isAbstract(); boolean isDeprecated(); } --- NEW FILE --- package net.sf.clirr.core.spi; /** * A Java source code entity like a type or a method that has the * concept of a visibility scope. * * Each entity has two scopes: One that is declared and the effective scope. * For example a public method can have an effective scope of package if it * appears in a class that is package visible. * * @author lk * */ public interface Scoped { /** * The declared scope of this entity. * @return the scope that appears in the modifiers of this entity. */ Scope getDeclaredScope(); /** * The effective Scope of this entity. * * @return the minimum scope of the modifiers of this entity and * it's all of it's containers. */ Scope getEffectiveScope(); } --- NEW FILE --- package net.sf.clirr.core.spi; /** * Describes a field of a class. */ public interface Field extends Named, Scoped { /** * The type of this field. */ JavaType getType(); /** * Whether the field is declared as final. */ boolean isFinal(); /** * Whether the field is declared as static. */ boolean isStatic(); /** * Whether the field is deprecated. */ boolean isDeprecated(); /** * Returns the constant value of this field. * The constant value is an Object if the field is static and final and the java compiler * could calculate the value at compilation time. * * @return the constant value or <code>null</code> if the compiler could * not calculate the value at compilation time */ Object getConstantValue(); } --- NEW FILE --- package net.sf.clirr.core.spi; /** * A Java Type (Object, Interface, primitive type or void). * * @author lkuehne */ public interface JavaType extends Named, Scoped { /** * Type fully qualified class name. * * @return a fully qualified class name, * like <code>"my.company.procuct.SampleClass"</code>. */ String getName(); /** * The containing class if this is an inner class. * * @return the containing class or <code>null</code> * if this JavaType does not represent an inner class. */ JavaType getContainingClass(); /** * Return the superclasses of this class. * * @return the chain of superclasses of this type, starting from * the direct superclass and ending with <code>java.lang.Object</code>. */ JavaType[] getSuperClasses(); /** * Return the list of all interfaces this class implements. * * @return the list of all interfaces this class implements/extends, * excluding <code>this</code> if this JavaType represents an interface itself. */ JavaType[] getAllInterfaces(); JavaType[] getInnerClasses(); /** * All methods that are declared by this class. * Methods of superclasses/interfaces are not returned * if they are not overridden/redeclared here. * * @return all methods that are declared by this class. */ Method[] getMethods(); /** * All fields that are declared by this class. * Fields of superclasses/interfaces are not returned. * * @return all fields that are declared by this class. */ Field[] getFields(); boolean isPrimitive(); boolean isArray(); boolean isFinal(); boolean isAbstract(); boolean isInterface(); } --- NEW FILE --- <html> <body> Service Provider Interface for letting Clirr know about Java types, methods, etc. This package is intended to <ul> <li> Decouple the current BCEL implementation from the comparison algorithms (separation of concerns). </li> <li> Allow IDE plugins to provide an implementation that is based on the internal Java representation of the IDE. This allows instantatious error marker feedback, building class files or jars on disk is not required. </li> </ul> </body> </html> |
From: <lk...@us...> - 2005-08-26 05:29:45
|
Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/spi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7605/src/java/net/sf/clirr/core/spi Log Message: Directory /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/spi added to the repository |
From: Simon K. <ski...@ap...> - 2005-08-24 10:13:20
|
On Mon, 2005-08-22 at 21:05 +0200, Lars Kühne wrote: > Hi, > > if nobody objects within the next few days, I will commit changes to > clirr-core that introduce an SPI for providing the Java code structure. > I think I discussed the idea with Simon a while ago, the basic idea is > to let the checks work against a the interfaces /JavaType,/ /Field/ and > /Method/ instead of working directly against the BCEL classes. > > This change has three major objectives: > > * decouple our core logic from external dependencies (in this case BCEL) > * allow replacing BCEL with a faster/smaller/more-full-featured > (think Java5) byte code lib. ASM would be one of the candidates > * allow Clirr IDE plugins to use their IDE's internal code > representation, so compilation to class files is not required. It > should be possible to write a plugin that lets users detect > incompatible changes while they are typing the code. > > All existing tests still pass, but this change could cause problems for > some corner cases that are currently untested. > > Let me know what you think. Sounds fine - though I would also be happy with just swapping to use ASM directly. I've been wondering whether we should look at restructuring the code to work more like an asm "visitor" or how checkstyle works than the current layout, because last I looked the method tests were getting rather complex. But of course last time I looked was quite a while ago! I presume your new code will still essentially encapsulate an in-memory "model" of classes that the checks then inspect rather that try to be more ASM-ish?? Cheers, Simon |
From: SourceForge.net <no...@so...> - 2005-08-23 15:03:14
|
Bugs item #1267189, was opened at 2005-08-23 17:03 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=590799&aid=1267189&group_id=89627 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Ant Task Group: None Status: Open Resolution: None Priority: 5 Submitted By: Lars Kühne (lkuehne) Assigned to: Lars Kühne (lkuehne) Summary: Ant: Class exclusion via <apiclasses> is broken Initial Comment: I use <apiclasses> <exclude name="**/internal/**"/> </apiclasses> but for example I still get de.ppi.swing.table.internal.sort.SortButtonIconFactory = true and Clirr reports incompatibilities for classes inside the internal hierarchy ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=590799&aid=1267189&group_id=89627 |
From: Vincent M. <vm...@pi...> - 2005-08-22 19:47:28
|
> -----Original Message----- > From: cli...@li... [mailto:clirr-devel- > ad...@li...] On Behalf Of Lars K=FChne > Sent: lundi 22 ao=FBt 2005 21:05 > To: cli...@li... > Subject: [Clirr-devel] about to commit changes to support a SPI >=20 > Hi, >=20 > if nobody objects within the next few days, I will commit changes to > clirr-core that introduce an SPI for providing the Java code = structure. > I think I discussed the idea with Simon a while ago, the basic idea is > to let the checks work against a the interfaces /JavaType,/ /Field/ = and > /Method/ instead of working directly against the BCEL classes. >=20 > This change has three major objectives: >=20 > * decouple our core logic from external dependencies (in this case > BCEL) > * allow replacing BCEL with a faster/smaller/more-full-featured > (think Java5) byte code lib. ASM would be one of the candidates > * allow Clirr IDE plugins to use their IDE's internal code > representation, so compilation to class files is not required. = It > should be possible to write a plugin that lets users detect > incompatible changes while they are typing the code. >=20 > All existing tests still pass, but this change could cause problems = for > some corner cases that are currently untested. >=20 > Let me know what you think. Sounds good to me. -Vincent |
From: <lak...@t-...> - 2005-08-22 19:01:23
|
Hi, if nobody objects within the next few days, I will commit changes to clirr-core that introduce an SPI for providing the Java code structure. I think I discussed the idea with Simon a while ago, the basic idea is to let the checks work against a the interfaces /JavaType,/ /Field/ and /Method/ instead of working directly against the BCEL classes. This change has three major objectives: * decouple our core logic from external dependencies (in this case BCEL) * allow replacing BCEL with a faster/smaller/more-full-featured (think Java5) byte code lib. ASM would be one of the candidates * allow Clirr IDE plugins to use their IDE's internal code representation, so compilation to class files is not required. It should be possible to write a plugin that lets users detect incompatible changes while they are typing the code. All existing tests still pass, but this change could cause problems for some corner cases that are currently untested. Let me know what you think. Cheers, Lars |
From: <lk...@us...> - 2005-08-22 04:05:32
|
Update of /cvsroot/clirr/clirr/core/src/test/net/sf/clirr/core/internal/checks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11091/src/test/net/sf/clirr/core/internal/checks Added Files: InterfaceSetCheckTest.java Log Message: added tests for InterfaceSet --- NEW FILE --- package net.sf.clirr.core.internal.checks; import net.sf.clirr.core.Severity; import net.sf.clirr.core.internal.ClassChangeCheck; public class InterfaceSetCheckTest extends AbstractCheckTestCase { public void testHierarchyChangesAreReported() throws Exception { ExpectedDiff[] expected = new ExpectedDiff[] { new ExpectedDiff("Added java.awt.event.WindowListener to the set of implemented interfaces", Severity.INFO, "testlib.ChangingHierarchy", null, null), new ExpectedDiff("Added java.awt.event.WindowFocusListener to the set of implemented interfaces", Severity.INFO, "testlib.ChangingHierarchy", null, null), new ExpectedDiff("Added java.awt.event.WindowStateListener to the set of implemented interfaces", Severity.INFO, "testlib.ChangingHierarchy", null, null), new ExpectedDiff("Removed java.awt.event.MouseListener from the set of implemented interfaces", Severity.ERROR, "testlib.ChangingHierarchy", null, null), }; verify(expected); } protected ClassChangeCheck createCheck(TestDiffListener tdl) { return new InterfaceSetCheck(tdl); } } |