[Fb-contrib-commit] SF.net SVN: fb-contrib: [407] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/uti
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2006-04-07 13:53:26
|
Revision: 407 Author: dbrosius Date: 2006-04-07 06:53:12 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=407&view=rev Log Message: ----------- Move version change control into a separate utility class Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 12:28:07 UTC (rev 406) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java 2006-04-07 13:53:12 UTC (rev 407) @@ -1,6 +1,5 @@ package com.mebigfatguy.fbcontrib.detect; -import java.lang.reflect.Member; import java.util.BitSet; import java.util.HashMap; import java.util.Map; @@ -11,13 +10,13 @@ import org.apache.bcel.generic.Type; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; +import com.mebigfatguy.fbcontrib.utils.VersionTransition; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.StatelessDetector; -import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for methods that synchronize on variables that are not owned by the @@ -51,17 +50,6 @@ return super.clone(); } - private static java.lang.reflect.Method gbs; - private static BitSet transition_getBytecodeSet(ClassContext classContext, Method m) { - try { - if (gbs == null) - gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); - return (BitSet)gbs.invoke(classContext, new Object[] { m }); - } catch (Exception e) { - return new BitSet(); - } - } - /** * looks for methods that contain a MONITORENTER opcode * @@ -69,7 +57,7 @@ * @return if the class uses synchronization */ public boolean prescreen(Method method) { - BitSet bytecodeSet = transition_getBytecodeSet(getClassContext(), method); + BitSet bytecodeSet = VersionTransition.getBytecodeSet(getClassContext(), method); return bytecodeSet != null && (bytecodeSet.get(Constants.MONITORENTER)); } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java 2006-04-07 13:53:12 UTC (rev 407) @@ -0,0 +1,34 @@ +package com.mebigfatguy.fbcontrib.utils; + +import java.util.BitSet; + +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * supports different versions/changes to the FindBugs.jar file, by using reflection, etc + * to use different signatures. + */ +public class VersionTransition { + + private static java.lang.reflect.Method gbs; + + /** + * manages the change to ClassContext getBytecodeSet from member to static method + * + * @param classContext the context object for the current class + * @param m the method to get the bytecode set for + * @return the byte code set + */ + + public static BitSet getBytecodeSet(ClassContext classContext, Method m) { + try { + if (gbs == null) + gbs = ClassContext.class.getMethod("getBytecodeSet", new Class[] { Method.class }); + return (BitSet)gbs.invoke(classContext, new Object[] { m }); + } catch (Exception e) { + return new BitSet(); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |