harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r489652 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/io/ java/net/ org/apache/harmony/luni/internal/process/ org/apache/harmony/luni/platform/
Date Fri, 22 Dec 2006 13:49:05 GMT
Author: tellison
Date: Fri Dec 22 05:49:04 2006
New Revision: 489652

URL: http://svn.apache.org/viewvc?view=rev&rev=489652
Log:
Apply slightly modified version of patch for HARMONY-2840
[classlib] [luni] Some inner classes could be removed or changed to static inner classes (FindBugs)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileInputStream.java
Fri Dec 22 05:49:04 2006
@@ -45,7 +45,7 @@
 
     private IFileSystem fileSystem = Platform.getFileSystem();
 
-    private class RepositioningLock {}
+    private static class RepositioningLock {}
     private Object repositioningLock = new RepositioningLock();
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
Fri Dec 22 05:49:04 2006
@@ -122,7 +122,7 @@
 	}
 
     // Internal type used to keep track of validators & corresponding priority
-    class InputValidationDesc {
+    static class InputValidationDesc {
         ObjectInputValidation validator;
 
         int priority;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java Fri
Dec 22 05:49:04 2006
@@ -39,12 +39,6 @@
 		Closeable {
 
     private static final String TOKEN_NULL = "null"; //$NON-NLS-1$
-    
-	/**
-	 * protect writes to the underlying stream.
-	 */
-    private class Lock {} 
-	private Object lock = new Lock();
 
 	/**
 	 * indicates whether or not this PrintStream has incurred an error.
@@ -244,16 +238,14 @@
 	 * 
 	 */
 	@Override
-    public void close() {
-		synchronized (lock) {
-			flush();
-			if (out != null) {
-				try {
-					out.close();
-					out = null;
-				} catch (IOException e) {
-					setError();
-				}
+    public synchronized void close() {
+		flush();
+		if (out != null) {
+			try {
+				out.close();
+				out = null;
+			} catch (IOException e) {
+				setError();
 			}
 		}
 	}
@@ -265,14 +257,12 @@
 	 * 
 	 */
 	@Override
-    public void flush() {
-		synchronized (lock) {
-			if (out != null) {
-				try {
-					out.flush();
-					return;
-				} catch (IOException e) {
-				}
+    public synchronized void flush() {
+		if (out != null) {
+			try {
+				out.flush();
+				return;
+			} catch (IOException e) {
 			}
 		}
 		setError();
@@ -472,26 +462,24 @@
 	 * @param str
 	 *            the <code>String</code> to print on this PrintStream.
 	 */
-	public void print(String str) {
-		synchronized (lock) {
-			if (out == null) {
-				setError();
-				return;
-			}
-			if (str == null) {
-				print("null"); //$NON-NLS-1$
-				return;
-			}
+	public synchronized void print(String str) {
+		if (out == null) {
+			setError();
+			return;
+		}
+		if (str == null) {
+			print("null"); //$NON-NLS-1$
+			return;
+		}
 
-			try {
-				if (encoding == null) {
-                    write(str.getBytes());
-                } else {
-                    write(str.getBytes(encoding));
-                }
-			} catch (IOException e) {
-				setError();
-			}
+		try {
+			if (encoding == null) {
+                write(str.getBytes());
+            } else {
+                write(str.getBytes(encoding));
+            }
+		} catch (IOException e) {
+			setError();
 		}
 	}
 
@@ -607,11 +595,9 @@
 	 * @param str
 	 *            the <code>String</code> to print on this PrintStream.
 	 */
-	public void println(String str) {
-		synchronized (lock) {
-			print(str);
-			newline();
-		}
+	public synchronized void println(String str) {
+		print(str);
+		newline();
 	}
 
 	/**
@@ -654,7 +640,7 @@
 			// avoid int overflow
 			if (0 <= offset && offset <= buffer.length && 0 <= count
 					&& count <= buffer.length - offset) {
-				synchronized (lock) {
+				synchronized (this) {
 					if (out == null) {
 						setError();
 						return;
@@ -688,20 +674,18 @@
 	 *            the byte to be written
 	 */
 	@Override
-    public void write(int oneByte) {
-		synchronized (lock) {
-			if (out == null) {
-				setError();
-				return;
-			}
-			try {
-				out.write(oneByte);
-				if (autoflush && (oneByte & 0xFF) == '\n') {
-                    flush();
-                }
-			} catch (IOException e) {
-				setError();
-			}
+    public synchronized void write(int oneByte) {
+		if (out == null) {
+			setError();
+			return;
+		}
+		try {
+			out.write(oneByte);
+			if (autoflush && (oneByte & 0xFF) == '\n') {
+                flush();
+            }
+		} catch (IOException e) {
+			setError();
 		}
 	}
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/RandomAccessFile.java
Fri Dec 22 05:49:04 2006
@@ -48,7 +48,7 @@
 
     private boolean isReadOnly;
 
-    private class RepositionLock {
+    private static class RepositionLock {
     }
 
     private Object repositionLock = new RepositionLock();

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/DatagramSocket.java
Fri Dec 22 05:49:04 2006
@@ -46,7 +46,7 @@
 
 	private boolean isClosed = false;
 
-    private class Lock {}
+    private static class Lock {}
 	private Object lock = new Lock();
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java Fri
Dec 22 05:49:04 2006
@@ -61,7 +61,7 @@
 
 	String hostName;
 	
-    private class WaitReachable {}
+    private static class WaitReachable {}
     private transient Object waitReachable = new WaitReachable();
     
     private boolean reached;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java Fri Dec
22 05:49:04 2006
@@ -51,7 +51,7 @@
 
     private boolean isOutputShutdown = false;
 
-    private class ConnectLock {}
+    private static class ConnectLock {}
     private Object connectLock = new ConnectLock();
 
     private Proxy proxy;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
Fri Dec 22 05:49:04 2006
@@ -1039,7 +1039,7 @@
 		return getClass().getName() + ":" + url.toString();
 	}
 
-	class DefaultContentHandler extends java.net.ContentHandler {
+	static class DefaultContentHandler extends java.net.ContentHandler {
 
 		/**
 		 * @param u

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
Fri Dec 22 05:49:04 2006
@@ -71,7 +71,7 @@
 
         final SystemProcess p = new SystemProcess();
 
-        p.lock = p.new Lock();
+        p.lock = new Lock();
 
         Runnable waitingThread = new Runnable() {
             public void run() {
@@ -160,7 +160,7 @@
 
     private int exitCode;
 
-    private class Lock {}
+    private static class Lock {}
     private Object lock;
 
     private boolean waiterStarted;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java?view=diff&rev=489652&r1=489651&r2=489652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/AbstractMemorySpy.java
Fri Dec 22 05:49:04 2006
@@ -37,10 +37,7 @@
 
 	protected ReferenceQueue<Object> notifyQueue = new ReferenceQueue<Object>();
 
-    private class Lock {}
-	protected Object lock = new Lock();
-
-	final class AddressWrapper {
+   	final class AddressWrapper {
 		final PlatformAddress shadow;
 
 		final PhantomReference<PlatformAddress> wrAddress;
@@ -60,7 +57,7 @@
 
 	public void alloc(PlatformAddress address) {
 		AddressWrapper wrapper = new AddressWrapper(address);
-		synchronized (lock) {
+		synchronized (this) {
 			memoryInUse.put(wrapper.shadow, wrapper);
 			refToShadow.put(wrapper.wrAddress, wrapper.shadow);
 		}
@@ -68,7 +65,7 @@
 
 	public boolean free(PlatformAddress address) {
 		AddressWrapper wrapper;
-		synchronized (lock) {
+		synchronized (this) {
 			wrapper = memoryInUse.remove(address);
 		}
 		if (wrapper == null) {
@@ -91,7 +88,7 @@
 	 */
 	public void autoFree(PlatformAddress address) {
 		AddressWrapper wrapper;
-		synchronized (lock) {
+		synchronized (this) {
 			wrapper = memoryInUse.get(address);
 		}
 		if (wrapper != null) {
@@ -101,7 +98,7 @@
 
 	protected void orphanedMemory(Reference ref) {
 		AddressWrapper wrapper;
-		synchronized (lock) {
+		synchronized (this) {
 			PlatformAddress shadow = refToShadow.remove(ref);
 			wrapper = memoryInUse.remove(shadow);
 		}



Mime
View raw message