Author: j...@google.com
Date: Thu May 14 19:24:00 2009
New Revision: 5380

Modified:
    changes/jat/findbugs/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
     
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/javac/AnnotationProxyFactory.java
     
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/util/log/AbstractTreeLogger.java
     
changes/jat/findbugs/samples/dynatable/src/com/google/gwt/sample/dynatable/client/TimeSlot.java
     
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Contacts.java
     
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Mail.java
     
changes/jat/findbugs/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
     
changes/jat/findbugs/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPC.java
    changes/jat/findbugs/user/src/com/google/gwt/user/client/Event.java
     
changes/jat/findbugs/user/src/com/google/gwt/user/datepicker/client/CellGridImpl.java
     
changes/jat/findbugs/user/super/com/google/gwt/emul/java/sql/Timestamp.java

Log:
Finish up the rest of my FindBugs issues.

Patch by:  jat


Modified:  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
==============================================================================
--- changes/jat/findbugs/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java     
 
(original)
+++ changes/jat/findbugs/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java     
 
Thu May 14 19:24:00 2009
@@ -240,8 +240,7 @@
      return name;
    }

-  // TODO(FINDBUGS): inconsistent synchronization
-  public CompilationState getCompilationState(TreeLogger logger)
+  public synchronized CompilationState getCompilationState(TreeLogger  
logger)
        throws UnableToCompleteException {
      if (lazyCompilationState == null) {
        lazyCompilationState = new CompilationState(logger,  
lazySourceOracle);
@@ -356,8 +355,7 @@
     * Override the module's apparent name. Setting this value to
     * <code>null<code> will disable the name override.
     */
-  // TODO(FINDBUGS): inconsistent synchronization
-  public void setNameOverride(String nameOverride) {
+  public synchronized void setNameOverride(String nameOverride) {
      this.nameOverride = nameOverride;
    }

@@ -367,8 +365,8 @@
     *
     * NOTE: this method is for testing only.
     *
-   * @param partialPath
-   * @return
+   * @param partialPath the partial path of the source file
+   * @return the resource for the requested source file
     */
    synchronized Resource findSourceFile(String partialPath) {
      return lazySourceOracle.getResourceMap().get(partialPath);

Modified:  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/javac/AnnotationProxyFactory.java
==============================================================================
---  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/javac/AnnotationProxyFactory.java
   
(original)
+++  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/javac/AnnotationProxyFactory.java
   
Thu May 14 19:24:00 2009
@@ -93,8 +93,10 @@
      }

      @Override
-    // TODO(FINDBUGS): asymmetric equals with Annotation
      public boolean equals(Object other) {
+      // This is not actually an asymmetric equals implementation, as this
+      // method gets called for our proxy instance rather than on the  
handler
+      // itself.
        if (proxy == other) {
          return true;
        }

Modified:  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/util/log/AbstractTreeLogger.java
==============================================================================
---  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/util/log/AbstractTreeLogger.java
    
(original)
+++  
changes/jat/findbugs/dev/core/src/com/google/gwt/dev/util/log/AbstractTreeLogger.java
    
Thu May 14 19:24:00 2009
@@ -122,6 +122,9 @@
      AbstractTreeLogger childLogger = doBranch();

      // Set up the child logger.
+    //
+    // Unsynchronized operations on childLogger are safe since no other
+    // thread could have a reference to it yet.
      childLogger.logLevel = logLevel;

      // Take a snapshot of the index that the branched child should have.

Modified:  
changes/jat/findbugs/samples/dynatable/src/com/google/gwt/sample/dynatable/client/TimeSlot.java
==============================================================================
---  
changes/jat/findbugs/samples/dynatable/src/com/google/gwt/sample/dynatable/client/TimeSlot.java
  
(original)
+++  
changes/jat/findbugs/samples/dynatable/src/com/google/gwt/sample/dynatable/client/TimeSlot.java
  
Thu May 14 19:24:00 2009
@@ -57,6 +57,14 @@
      return 0;
    }

+  @Override
+  public boolean equals(Object obj) {
+    if (!(obj instanceof TimeSlot)) {
+      return false;
+    }
+    return compareTo((TimeSlot) obj) == 0;
+  }
+
    public int getDayOfWeek() {
      return zeroBasedDayOfWeek;
    }
@@ -72,6 +80,11 @@

    public int getStartMinutes() {
      return startMinutes;
+  }
+
+  @Override
+  public int hashCode() {
+    return endMinutes + 7 * startMinutes + 31 * zeroBasedDayOfWeek;
    }

    public void setDayOfWeek(int zeroBasedDayOfWeek) {

Modified:  
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Contacts.java
==============================================================================
---  
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Contacts.java
    
(original)
+++  
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Contacts.java
    
Thu May 14 19:24:00 2009
@@ -43,7 +43,7 @@
    /**
     * Simple data structure representing a contact.
     */
-  private class Contact {
+  private static class Contact {
      public String email;
      public String name;


Modified:  
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Mail.java
==============================================================================
---  
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Mail.java
        
(original)
+++  
changes/jat/findbugs/samples/mail/src/com/google/gwt/sample/mail/client/Mail.java
        
Thu May 14 19:24:00 2009
@@ -42,7 +42,7 @@
    private static final Images images = GWT.create(Images.class);

    /**
-   * An aggragate image bundle that pulls together all the images for this
+   * An aggregate image bundle that pulls together all the images for this
     * application into a single bundle.
     */
    public interface Images extends Shortcuts.Images, TopPanel.Images {

Modified:  
changes/jat/findbugs/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
==============================================================================
---  
changes/jat/findbugs/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
    
(original)
+++  
changes/jat/findbugs/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java
    
Thu May 14 19:24:00 2009
@@ -148,7 +148,7 @@
    /**
     * The current style theme.
     */
-  public static String CUR_THEME = ShowcaseConstants.STYLE_THEMES[0];
+  static String CUR_THEME = ShowcaseConstants.STYLE_THEMES[0];

    /**
     * Get the URL of the page, without an hash of query string.

Modified:  
changes/jat/findbugs/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPC.java
==============================================================================
---  
changes/jat/findbugs/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPC.java
         
(original)
+++  
changes/jat/findbugs/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPC.java
         
Thu May 14 19:24:00 2009
@@ -56,8 +56,8 @@

      // Should print a table of key value pairs.
      List<Integer> indexes = new ArrayList<Integer>();
-    indexes.add(new Integer(0));
-    indexes.add(new Integer(2));
+    indexes.add(Integer.valueOf(0));
+    indexes.add(Integer.valueOf(2));
      simpleRPCService.getMultipleStrings(indexes,  
getMultipleStringsCallback);
    }


Modified:  
changes/jat/findbugs/user/src/com/google/gwt/user/client/Event.java
==============================================================================
--- changes/jat/findbugs/user/src/com/google/gwt/user/client/Event.java  
(original)
+++ changes/jat/findbugs/user/src/com/google/gwt/user/client/Event.java Thu  
May 14 19:24:00 2009
@@ -431,7 +431,8 @@
     * @return the element's event listener
     */
    public static EventListener getEventListener(Element elem) {
-    // TODO(FINDBUGS): is this cast guaranteed to succeed?
+    // This cast is always valid because both Element types are JSOs and  
have
+    // no new fields are added in the subclass.
      return DOM.getEventListener((com.google.gwt.user.client.Element) elem);
    }

@@ -443,7 +444,8 @@
     *         values are described in {...@link Event})
     */
    public static int getEventsSunk(Element elem) {
-    // TODO(FINDBUGS): is this cast guaranteed to succeed?
+    // This cast is always valid because both Element types are JSOs and  
have
+    // no new fields are added in the subclass.
      return DOM.getEventsSunk((com.google.gwt.user.client.Element) elem);
    }

@@ -499,7 +501,8 @@
     * @param listener the listener to receive {...@link Event events}
     */
    public static void setEventListener(Element elem, EventListener  
listener) {
-    // TODO(FINDBUGS): is this cast guaranteed to succeed?
+    // This cast is always valid because both Element types are JSOs and  
have
+    // no new fields are added in the subclass.
      DOM.setEventListener((com.google.gwt.user.client.Element) elem,  
listener);
    }

@@ -513,7 +516,8 @@
     *          possible values are described in {...@link Event})
     */
    public static void sinkEvents(Element elem, int eventBits) {
-    // TODO(FINDBUGS): is this cast guaranteed to succeed?
+    // This cast is always valid because both Element types are JSOs and  
have
+    // no new fields are added in the subclass.
      DOM.sinkEvents((com.google.gwt.user.client.Element) elem, eventBits);
    }

@@ -552,7 +556,7 @@
     * Gets the element from which the mouse pointer was moved (only valid  
for
     * {...@link Event#ONMOUSEOVER}).
     *
-   * @deprecated use {...@link NativeEvent#getRelatedTarget()} instead
+   * @deprecated use {...@link NativeEvent#getRelatedEventTarget()} instead
     * @return the element from which the mouse pointer was moved
     */
    @Deprecated
@@ -597,7 +601,7 @@
     * Gets the element to which the mouse pointer was moved (only valid for
     * {...@link Event#ONMOUSEOUT}).
     *
-   * @deprecated use {...@link NativeEvent#getRelatedTarget()} instead
+   * @deprecated use {...@link NativeEvent#getRelatedEventTarget()} instead
     * @return the element to which the mouse pointer was moved
     */
    @Deprecated

Modified:  
changes/jat/findbugs/user/src/com/google/gwt/user/datepicker/client/CellGridImpl.java
==============================================================================
---  
changes/jat/findbugs/user/src/com/google/gwt/user/datepicker/client/CellGridImpl.java
    
(original)
+++  
changes/jat/findbugs/user/src/com/google/gwt/user/datepicker/client/CellGridImpl.java
    
Thu May 14 19:24:00 2009
@@ -148,7 +148,8 @@
    }

    public Cell getCell(Element element) {
-    // TODO(FINDBUGS): is this cast guaranteed to succeed?
+    // This cast is always valid because both Element types are JSOs and  
have
+    // no new fields are added in the subclass.
      return elementToCell.get((com.google.gwt.user.client.Element) element);
    }


Modified:  
changes/jat/findbugs/user/super/com/google/gwt/emul/java/sql/Timestamp.java
==============================================================================
---  
changes/jat/findbugs/user/super/com/google/gwt/emul/java/sql/Timestamp.java     
 
(original)
+++  
changes/jat/findbugs/user/super/com/google/gwt/emul/java/sql/Timestamp.java     
 
Thu May 14 19:24:00 2009
@@ -89,20 +89,21 @@
          || (getTime() == ts.getTime() && getNanos() < ts.getNanos());
    }

+  @Override
    public int compareTo(java.util.Date o) {
      // JavaDoc says a ClassCastException is correct behavior
      return compareTo((Timestamp) o);
    }

-  // TODO(FINDBUGS): should it implement compareTo(Object)?
    public int compareTo(Timestamp o) {
      int delta = (int) (getTime() - o.getTime());
      return delta == 0 ? getNanos() - o.getNanos() : delta;
    }

-  // TODO(FINDBUGS): asymmetric equals
+  @Override
    public boolean equals(Object ts) {
      // Timestamps can't be compared to java.util.Date
+    // This is known to not be symmetric, which follows the JRE.
      return ts instanceof Timestamp ? equals((Timestamp) ts) : false;
    }

@@ -114,10 +115,12 @@
      return nanos;
    }

+  @Override
    public long getTime() {
      return super.getTime();
    }

+  @Override
    public int hashCode() {
      // This is correct, per the Javadoc
      return super.hashCode();
@@ -133,11 +136,13 @@
      super.setTime((getTime() / 1000) * 1000 + (nanos / 1000000));
    }

+  @Override
    public void setTime(long time) {
      super.setTime(time);
      nanos = (((int) (time % 1000)) * 1000000);
    }

+  @Override
    public String toString() {
      return String.valueOf(1900 + getYear()) + "-" + padTwo(1 + getMonth())
          + "-" + padTwo(getDate()) + " " + padTwo(getHours()) + ":"

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to