harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r946120 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/awt/ classlib/modules/awt/src/main/native/gl/windows/ classlib/modules/awt/src/main/native/jpegdecoder/windows/ classlib/modules/awt/sr...
Date Wed, 19 May 2010 10:56:01 GMT
Author: hindessm
Date: Wed May 19 10:56:01 2010
New Revision: 946120

URL: http://svn.apache.org/viewvc?rev=946120&view=rev
Log:
Merging changes from trunk@945584

Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/awt/build.xml
    harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/gl/windows/makefile
    harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/jpegdecoder/windows/makefile
    harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/lcmm/windows/makefile
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/build.xml
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/jpegencoder/windows/makefile
    harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/pngencoder/windows/makefile
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
    harmony/enhanced/java/branches/java6/common_resources/   (props changed)
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 19 10:56:01 2010
@@ -1,3 +1,3 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-943968
+/harmony/enhanced/java/trunk:929253-945584
 /harmony/enhanced/trunk:810871-929252

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 19 10:56:01 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-943968
+/harmony/enhanced/java/trunk/classlib:929253-945584
 /harmony/enhanced/trunk/classlib:810871-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/working_classlib:423974-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 19 10:56:01 2010
@@ -1,3 +1,3 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-943968
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-945584
 /harmony/enhanced/trunk/classlib/depends/libs:810871-929252

Modified: harmony/enhanced/java/branches/java6/classlib/modules/awt/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/awt/build.xml?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/awt/build.xml (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/awt/build.xml Wed May 19 10:56:01
2010
@@ -229,19 +229,22 @@ ${line.separator}For Fedora try: yum ins
     <target name="-build-native-common" unless="skip.native.build">
         <make dir="src/main/native/lcmm/${hy.os.family}">
             <make-elements>
-                <env key="HY_LCMS_VER" value="${lcms.ver}" />
+                <env key="HY_LCMS_DIR" value="${lcms.dir}" />
             </make-elements>
         </make>
 
+        <pathconvert targetos="windows" property="jpeg.dir.win">
+            <path location="${jpeg.dir}" />
+        </pathconvert>
         <make dir="src/main/native/jpegdecoder/${hy.os.family}">
             <make-elements>
-                <env key="HY_JPEG_VER" value="${jpeg.ver}" />
+                <env key="HY_JPEG_DIR" value="${jpeg.dir.win}" />
             </make-elements>
         </make>
 
         <make dir="src/main/native/gl/${hy.os.family}">
             <make-elements>
-                <env key="HY_PNG_VER" value="${png.ver}" />
+                <env key="HY_PNG_DIR" value="${png.dir}" />
             </make-elements>
         </make>
         

Modified: harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/gl/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/gl/windows/makefile?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/gl/windows/makefile
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/gl/windows/makefile
Wed May 19 10:56:01 2010
@@ -16,7 +16,7 @@
 APPVER = 5.0 # Need WINVER=0x0500 to get HMONITOR defined.
 !include <$(HY_HDK)\build\make\defines.mak>
 
-PNG_DIR=$(HY_HDK)\..\depends\libs\$(HY_PLATFORM)\libpng-$(HY_PNG_VER)\# avoid continuation
+PNG_DIR=$(HY_PNG_DIR)\# avoid continuation
 
 LIBBASE=gl
 DLLNAME=$(DLLPATH)$(LIBBASE).dll

Modified: harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/jpegdecoder/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/jpegdecoder/windows/makefile?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/jpegdecoder/windows/makefile
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/jpegdecoder/windows/makefile
Wed May 19 10:56:01 2010
@@ -15,7 +15,7 @@
 
 !include <$(HY_HDK)\build\make\defines.mak>
 
-JPEG_DIR=$(HY_HDK)\..\depends\libs\$(HY_PLATFORM)\jpeg-$(HY_JPEG_VER)\# avoid continuation
+JPEG_DIR=$(HY_JPEG_DIR)\# avoid continuation
 
 LIBBASE=jpegdecoder
 DLLNAME=$(DLLPATH)$(LIBBASE).dll

Modified: harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/lcmm/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/lcmm/windows/makefile?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/lcmm/windows/makefile
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/awt/src/main/native/lcmm/windows/makefile
Wed May 19 10:56:01 2010
@@ -15,7 +15,7 @@
 
 !include <$(HY_HDK)\build\make\defines.mak>
 
-LCMS_DIR=$(HY_HDK)\..\depends\libs\$(HY_PLATFORM)\lcms-$(HY_LCMS_VER)\# avoid continuation
+LCMS_DIR=$(HY_LCMS_DIR)\# avoid continuation
 
 LIBBASE=lcmm
 DLLNAME=$(DLLPATH)$(LIBBASE).dll

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/build.xml?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/build.xml (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/build.xml Wed May 19 10:56:01
2010
@@ -135,15 +135,18 @@ ${line.separator}For Fedora try: yum ins
     </target>
     
     <target name="-build-native" unless="skip.native.build">
+        <pathconvert targetos="windows" property="jpeg.dir.win">
+            <path location="${jpeg.dir}" />
+        </pathconvert>
         <make dir="src/main/native/jpegencoder/${hy.os.family}">
             <make-elements>
-                <env key="HY_JPEG_VER" value="${jpeg.ver}" />
+                <env key="HY_JPEG_DIR" value="${jpeg.dir.win}" />
             </make-elements>
         </make>
 
         <make dir="src/main/native/pngencoder/${hy.os.family}">
             <make-elements>
-                <env key="HY_PNG_VER" value="${png.ver}" />
+                <env key="HY_PNG_DIR" value="${png.dir}" />
             </make-elements>
         </make>
     </target>

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/jpegencoder/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/jpegencoder/windows/makefile?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/jpegencoder/windows/makefile
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/jpegencoder/windows/makefile
Wed May 19 10:56:01 2010
@@ -15,7 +15,7 @@
 
 !include <$(HY_HDK)\build\make\defines.mak>
 
-JPEG_DIR=$(HY_HDK)\..\depends\libs\$(HY_PLATFORM)\jpeg-$(HY_JPEG_VER)\# avoid continuation
+JPEG_DIR=$(HY_JPEG_DIR)\# avoid continuation
 
 LIBBASE=jpegencoder
 DLLNAME=$(DLLPATH)$(LIBBASE).dll

Modified: harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/pngencoder/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/pngencoder/windows/makefile?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/pngencoder/windows/makefile
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/imageio/src/main/native/pngencoder/windows/makefile
Wed May 19 10:56:01 2010
@@ -15,7 +15,7 @@
 
 !include <$(HY_HDK)\build\make\defines.mak>
 
-PNG_DIR=$(HY_HDK)\..\depends\libs\$(HY_PLATFORM)\libpng-$(HY_PNG_VER)\# avoid continuation
+PNG_DIR=$(HY_PNG_DIR)\# avoid continuation
 
 LIBBASE=pngencoder
 DLLNAME=$(DLLPATH)$(LIBBASE).dll

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
Wed May 19 10:56:01 2010
@@ -24,28 +24,28 @@ import java.util.StringTokenizer;
  */
 public class Inet6Util {
 
-	/**
-	 * Creates an byte[] based on an ipAddressString. No error handling is
-	 * performed here.
-	 */
-	public static byte[] createByteArrayFromIPAddressString(
-			String ipAddressString) {
+    /**
+     * Creates an byte[] based on an ipAddressString. No error handling is
+     * performed here.
+     */
+    public static byte[] createByteArrayFromIPAddressString(
+            String ipAddressString) {
 
-		if (isValidIPV4Address(ipAddressString)) {
+        if (isValidIPV4Address(ipAddressString)) {
             StringTokenizer tokenizer = new StringTokenizer(ipAddressString, ".");
-			String token = "";
-			int tempInt = 0;
-			byte[] byteAddress = new byte[4];
-			for (int i = 0; i < 4; i++) {
-				token = tokenizer.nextToken();
-				tempInt = Integer.parseInt(token);
-				byteAddress[i] = (byte) tempInt;
-			}
-
-			return byteAddress;
-		}
-		
-		if (ipAddressString.charAt(0) == '[') {
+            String token = "";
+            int tempInt = 0;
+            byte[] byteAddress = new byte[4];
+            for (int i = 0; i < 4; i++) {
+                token = tokenizer.nextToken();
+                tempInt = Integer.parseInt(token);
+                byteAddress[i] = (byte) tempInt;
+            }
+
+            return byteAddress;
+        }
+
+        if (ipAddressString.charAt(0) == '[') {
             ipAddressString = ipAddressString.substring(1, ipAddressString.length() - 1);
         }
 
@@ -63,235 +63,248 @@ public class Inet6Util {
          * or decimal list. In the case where we hit a :: we will save the index
          * of the hexStrings so we can add zeros in to fill out the string
          */
-		while (tokenizer.hasMoreTokens()) {
-			prevToken = token;
-			token = tokenizer.nextToken();
-
-			if (token.equals(":")) {
-				if (prevToken.equals(":")) {
-					doubleColonIndex = hexStrings.size();
-				} else if (!prevToken.equals("")) {
-					hexStrings.add(prevToken);
-				}
-			} else if (token.equals(".")) {
-				decStrings.add(prevToken);
-			}
-		}
-
-		if (prevToken.equals(":")) {
-			if (token.equals(":")) {
-				doubleColonIndex = hexStrings.size();
-			} else {
-				hexStrings.add(token);
-			}
-		} else if (prevToken.equals(".")) {
-			decStrings.add(token);
-		}
-
-		// figure out how many hexStrings we should have
-		// also check if it is a IPv4 address
-		int hexStringsLength = 8;
-
-		// If we have an IPv4 address tagged on at the end, subtract
-		// 4 bytes, or 2 hex words from the total
-		if (decStrings.size() > 0) {
-			hexStringsLength -= 2;
-		}
-
-		// if we hit a double Colon add the appropriate hex strings
-		if (doubleColonIndex != -1) {
-			int numberToInsert = hexStringsLength - hexStrings.size();
-			for (int i = 0; i < numberToInsert; i++) {
-				hexStrings.add(doubleColonIndex, "0");
-			}
-		}
-
-		byte ipByteArray[] = new byte[16];
-
-		// Finally convert these strings to bytes...
-		for (int i = 0; i < hexStrings.size(); i++) {
-			convertToBytes(hexStrings.get(i), ipByteArray, i * 2);
-		}
+        while (tokenizer.hasMoreTokens()) {
+            prevToken = token;
+            token = tokenizer.nextToken();
+
+            if (token.equals(":")) {
+                if (prevToken.equals(":")) {
+                    doubleColonIndex = hexStrings.size();
+                } else if (!prevToken.equals("")) {
+                    hexStrings.add(prevToken);
+                }
+            } else if (token.equals(".")) {
+                decStrings.add(prevToken);
+            }
+        }
 
-		// Now if there are any decimal values, we know where they go...
-		for (int i = 0; i < decStrings.size(); i++) {
+        if (prevToken.equals(":")) {
+            if (token.equals(":")) {
+                doubleColonIndex = hexStrings.size();
+            } else {
+                hexStrings.add(token);
+            }
+        } else if (prevToken.equals(".")) {
+            decStrings.add(token);
+        }
+
+        // figure out how many hexStrings we should have
+        // also check if it is a IPv4 address
+        int hexStringsLength = 8;
+
+        // If we have an IPv4 address tagged on at the end, subtract
+        // 4 bytes, or 2 hex words from the total
+        if (decStrings.size() > 0) {
+            hexStringsLength -= 2;
+        }
+
+        // if we hit a double Colon add the appropriate hex strings
+        if (doubleColonIndex != -1) {
+            int numberToInsert = hexStringsLength - hexStrings.size();
+            for (int i = 0; i < numberToInsert; i++) {
+                hexStrings.add(doubleColonIndex, "0");
+            }
+        }
+
+        byte ipByteArray[] = new byte[16];
+
+        // Finally convert these strings to bytes...
+        for (int i = 0; i < hexStrings.size(); i++) {
+            convertToBytes(hexStrings.get(i), ipByteArray, i * 2);
+        }
+
+        // Now if there are any decimal values, we know where they go...
+        for (int i = 0; i < decStrings.size(); i++) {
             ipByteArray[i + 12] = (byte) (Integer.parseInt(decStrings.get(i)) & 255);
         }
 
-		// now check to see if this guy is actually and IPv4 address
-		// an ipV4 address is ::FFFF:d.d.d.d
-		boolean ipV4 = true;
-		for (int i = 0; i < 10; i++) {
-			if (ipByteArray[i] != 0) {
-				ipV4 = false;
-				break;
-			}
-		}
-
-		if (ipByteArray[10] != -1 || ipByteArray[11] != -1) {
-			ipV4 = false;
-		}
-
-		if (ipV4) {
-			byte ipv4ByteArray[] = new byte[4];
-			for (int i = 0; i < 4; i++) {
-				ipv4ByteArray[i] = ipByteArray[i + 12];
-			}
-			return ipv4ByteArray;
-		}
-		
-		return ipByteArray;
-
-	}
-
-	static String hexCharacters = "0123456789ABCDEF";
-
-	public static String createIPAddrStringFromByteArray(byte ipByteArray[]) {
-		if (ipByteArray.length == 4) {
-			return addressToString(bytesToInt(ipByteArray, 0));
-		}
-
-		if (ipByteArray.length == 16) {
-			if (isIPv4MappedAddress(ipByteArray)) {
-				byte ipv4ByteArray[] = new byte[4];
-				for (int i = 0; i < 4; i++) {
-					ipv4ByteArray[i] = ipByteArray[i + 12];
-				}
-				return addressToString(bytesToInt(ipv4ByteArray, 0));
-			}
+        // now check to see if this guy is actually and IPv4 address
+        // an ipV4 address is ::FFFF:d.d.d.d
+        boolean ipV4 = true;
+        for (int i = 0; i < 10; i++) {
+            if (ipByteArray[i] != 0) {
+                ipV4 = false;
+                break;
+            }
+        }
+
+        if (ipByteArray[10] != -1 || ipByteArray[11] != -1) {
+            ipV4 = false;
+        }
+
+        if (ipV4) {
+            byte ipv4ByteArray[] = new byte[4];
+            for (int i = 0; i < 4; i++) {
+                ipv4ByteArray[i] = ipByteArray[i + 12];
+            }
+            return ipv4ByteArray;
+        }
+
+        return ipByteArray;
+
+    }
+
+    static String hexCharacters = "0123456789ABCDEF";
+
+    public static String createIPAddrStringFromByteArray(byte ipByteArray[]) {
+        if (ipByteArray.length == 4) {
+            return addressToString(bytesToInt(ipByteArray, 0));
+        }
+
+        if (ipByteArray.length == 16) {
+            if (isIPv4MappedAddress(ipByteArray)) {
+                byte ipv4ByteArray[] = new byte[4];
+                for (int i = 0; i < 4; i++) {
+                    ipv4ByteArray[i] = ipByteArray[i + 12];
+                }
+                return addressToString(bytesToInt(ipv4ByteArray, 0));
+            }
             StringBuilder buffer = new StringBuilder();
+            boolean isFirst = true;
             for (int i = 0; i < ipByteArray.length; i++) {
-            	int j = (ipByteArray[i] & 0xf0) >>> 4;
-            	buffer.append(hexCharacters.charAt(j));
-            	j = ipByteArray[i] & 0x0f;
-            	buffer.append(hexCharacters.charAt(j));
-            	if (i % 2 != 0 && (i + 1) < ipByteArray.length) {
-            		buffer.append(":");
-            	}
+                if ((i & 1) == 0) {
+                    isFirst = true;
+                }
+                int j = (ipByteArray[i] & 0xf0) >>> 4;
+                if (j != 0 || !isFirst) {
+                    buffer.append(hexCharacters.charAt(j));
+                    isFirst = false;
+                }
+                j = ipByteArray[i] & 0x0f;
+                if (j != 0 || !isFirst) {
+                    buffer.append(hexCharacters.charAt(j));
+                    isFirst = false;
+                }
+                if ((i & 1) != 0 && (i + 1) < ipByteArray.length) {
+                    if (isFirst) {
+                        buffer.append('0');
+                    }
+                    buffer.append(':');
+                }
             }
             return buffer.toString();
-		}
-		return null;
-	}
-
-	/** Converts a 4 character hex word into a 2 byte word equivalent */
-	public static void convertToBytes(String hexWord, byte ipByteArray[],
-			int byteIndex) {
-
-		int hexWordLength = hexWord.length();
-		int hexWordIndex = 0;
-		ipByteArray[byteIndex] = 0;
-		ipByteArray[byteIndex + 1] = 0;
-		int charValue;
-
-		// high order 4 bits of first byte
-		if (hexWordLength > 3) {
-			charValue = getIntValue(hexWord.charAt(hexWordIndex++));
-			ipByteArray[byteIndex] = (byte) (ipByteArray[byteIndex] | (charValue << 4));
-		}
-
-		// low order 4 bits of the first byte
-		if (hexWordLength > 2) {
-			charValue = getIntValue(hexWord.charAt(hexWordIndex++));
-			ipByteArray[byteIndex] = (byte) (ipByteArray[byteIndex] | charValue);
-		}
-
-		// high order 4 bits of second byte
-		if (hexWordLength > 1) {
-			charValue = getIntValue(hexWord.charAt(hexWordIndex++));
-			ipByteArray[byteIndex + 1] = (byte) (ipByteArray[byteIndex + 1] | (charValue <<
4));
-		}
-
-		// low order 4 bits of the first byte
-		charValue = getIntValue(hexWord.charAt(hexWordIndex));
-		ipByteArray[byteIndex + 1] = (byte) (ipByteArray[byteIndex + 1] | charValue & 15);
-	}
-
-	static int getIntValue(char c) {
-
-		switch (c) {
-		case '0':
-			return 0;
-		case '1':
-			return 1;
-		case '2':
-			return 2;
-		case '3':
-			return 3;
-		case '4':
-			return 4;
-		case '5':
-			return 5;
-		case '6':
-			return 6;
-		case '7':
-			return 7;
-		case '8':
-			return 8;
-		case '9':
-			return 9;
-		}
-
-		c = Character.toLowerCase(c);
-		switch (c) {
-		case 'a':
-			return 10;
-		case 'b':
-			return 11;
-		case 'c':
-			return 12;
-		case 'd':
-			return 13;
-		case 'e':
-			return 14;
-		case 'f':
-			return 15;
-		}
-		return 0;
-	}
-
-	private static boolean isIPv4MappedAddress(byte ipAddress[]) {
-
-		// Check if the address matches ::FFFF:d.d.d.d
-		// The first 10 bytes are 0. The next to are -1 (FF).
-		// The last 4 bytes are varied.
-		for (int i = 0; i < 10; i++) {
-			if (ipAddress[i] != 0) {
-				return false;
-			}
-		}
-
-		if (ipAddress[10] != -1 || ipAddress[11] != -1) {
-			return false;
-		}
-
-		return true;
-
-	}
-
-	/**
-	 * Takes the byte array and creates an integer out of four bytes starting at
-	 * start as the high-order byte. This method makes no checks on the validity
-	 * of the parameters.
-	 */
-	public static int bytesToInt(byte bytes[], int start) {
-		// First mask the byte with 255, as when a negative
-		// signed byte converts to an integer, it has bits
-		// on in the first 3 bytes, we are only concerned
-		// about the right-most 8 bits.
-		// Then shift the rightmost byte to align with its
-		// position in the integer.
-		int value = ((bytes[start + 3] & 255))
-				| ((bytes[start + 2] & 255) << 8)
-				| ((bytes[start + 1] & 255) << 16)
-				| ((bytes[start] & 255) << 24);
-		return value;
-	}
-
-	public static String addressToString(int value) {
-		return ((value >> 24) & 0xff) + "." + ((value >> 16) & 0xff) + "."
-				+ ((value >> 8) & 0xff) + "." + (value & 0xff);
-	}
+        }
+        return null;
+    }
+
+    /** Converts a 4 character hex word into a 2 byte word equivalent */
+    public static void convertToBytes(String hexWord, byte ipByteArray[],
+            int byteIndex) {
+
+        int hexWordLength = hexWord.length();
+        int hexWordIndex = 0;
+        ipByteArray[byteIndex] = 0;
+        ipByteArray[byteIndex + 1] = 0;
+        int charValue;
+
+        // high order 4 bits of first byte
+        if (hexWordLength > 3) {
+            charValue = getIntValue(hexWord.charAt(hexWordIndex++));
+            ipByteArray[byteIndex] = (byte) (ipByteArray[byteIndex] | (charValue <<
4));
+        }
+
+        // low order 4 bits of the first byte
+        if (hexWordLength > 2) {
+            charValue = getIntValue(hexWord.charAt(hexWordIndex++));
+            ipByteArray[byteIndex] = (byte) (ipByteArray[byteIndex] | charValue);
+        }
+
+        // high order 4 bits of second byte
+        if (hexWordLength > 1) {
+            charValue = getIntValue(hexWord.charAt(hexWordIndex++));
+            ipByteArray[byteIndex + 1] = (byte) (ipByteArray[byteIndex + 1] | (charValue
<< 4));
+        }
+
+        // low order 4 bits of the first byte
+        charValue = getIntValue(hexWord.charAt(hexWordIndex));
+        ipByteArray[byteIndex + 1] = (byte) (ipByteArray[byteIndex + 1] | charValue &
15);
+    }
+
+    static int getIntValue(char c) {
+
+        switch (c) {
+        case '0':
+            return 0;
+        case '1':
+            return 1;
+        case '2':
+            return 2;
+        case '3':
+            return 3;
+        case '4':
+            return 4;
+        case '5':
+            return 5;
+        case '6':
+            return 6;
+        case '7':
+            return 7;
+        case '8':
+            return 8;
+        case '9':
+            return 9;
+        }
+
+        c = Character.toLowerCase(c);
+        switch (c) {
+        case 'a':
+            return 10;
+        case 'b':
+            return 11;
+        case 'c':
+            return 12;
+        case 'd':
+            return 13;
+        case 'e':
+            return 14;
+        case 'f':
+            return 15;
+        }
+        return 0;
+    }
+
+    private static boolean isIPv4MappedAddress(byte ipAddress[]) {
+
+        // Check if the address matches ::FFFF:d.d.d.d
+        // The first 10 bytes are 0. The next to are -1 (FF).
+        // The last 4 bytes are varied.
+        for (int i = 0; i < 10; i++) {
+            if (ipAddress[i] != 0) {
+                return false;
+            }
+        }
+
+        if (ipAddress[10] != -1 || ipAddress[11] != -1) {
+            return false;
+        }
+
+        return true;
+
+    }
+
+    /**
+     * Takes the byte array and creates an integer out of four bytes starting at
+     * start as the high-order byte. This method makes no checks on the validity
+     * of the parameters.
+     */
+    public static int bytesToInt(byte bytes[], int start) {
+        // First mask the byte with 255, as when a negative
+        // signed byte converts to an integer, it has bits
+        // on in the first 3 bytes, we are only concerned
+        // about the right-most 8 bits.
+        // Then shift the rightmost byte to align with its
+        // position in the integer.
+        int value = ((bytes[start + 3] & 255))
+                | ((bytes[start + 2] & 255) << 8)
+                | ((bytes[start + 1] & 255) << 16)
+                | ((bytes[start] & 255) << 24);
+        return value;
+    }
+
+    public static String addressToString(int value) {
+        return ((value >> 24) & 0xff) + "." + ((value >> 16) & 0xff)
+ "."
+                + ((value >> 8) & 0xff) + "." + (value & 0xff);
+    }
 
     public static boolean isIP6AddressInFullForm(String ipAddress) {
         if (isValidIP6Address(ipAddress)) {
@@ -304,179 +317,179 @@ public class Inet6Util {
         }
         return false;
     }
-    
-	public static boolean isValidIP6Address(String ipAddress) {
-		int length = ipAddress.length();
-		boolean doubleColon = false;
-		int numberOfColons = 0;
-		int numberOfPeriods = 0;
-		int numberOfPercent = 0;
-		String word = "";
-		char c = 0;
-		char prevChar = 0;
-		int offset = 0; // offset for [] IP addresses
 
-		if (length < 2) {
+    public static boolean isValidIP6Address(String ipAddress) {
+        int length = ipAddress.length();
+        boolean doubleColon = false;
+        int numberOfColons = 0;
+        int numberOfPeriods = 0;
+        int numberOfPercent = 0;
+        String word = "";
+        char c = 0;
+        char prevChar = 0;
+        int offset = 0; // offset for [] IP addresses
+
+        if (length < 2) {
             return false;
         }
 
-		for (int i = 0; i < length; i++) {
-			prevChar = c;
-			c = ipAddress.charAt(i);
-			switch (c) {
-
-			// case for an open bracket [x:x:x:...x]
-			case '[':
-				if (i != 0) {
+        for (int i = 0; i < length; i++) {
+            prevChar = c;
+            c = ipAddress.charAt(i);
+            switch (c) {
+
+            // case for an open bracket [x:x:x:...x]
+            case '[':
+                if (i != 0) {
                     return false; // must be first character
                 }
-				if (ipAddress.charAt(length - 1) != ']') {
+                if (ipAddress.charAt(length - 1) != ']') {
                     return false; // must have a close ]
                 }
-				offset = 1;
-				if (length < 4) {
+                offset = 1;
+                if (length < 4) {
                     return false;
                 }
-				break;
+                break;
 
-			// case for a closed bracket at end of IP [x:x:x:...x]
-			case ']':
-				if (i != length - 1) {
+            // case for a closed bracket at end of IP [x:x:x:...x]
+            case ']':
+                if (i != length - 1) {
                     return false; // must be last character
                 }
-				if (ipAddress.charAt(0) != '[') {
+                if (ipAddress.charAt(0) != '[') {
                     return false; // must have a open [
                 }
-				break;
+                break;
 
-			// case for the last 32-bits represented as IPv4 x:x:x:x:x:x:d.d.d.d
-			case '.':
-				numberOfPeriods++;
-				if (numberOfPeriods > 3) {
+            // case for the last 32-bits represented as IPv4 x:x:x:x:x:x:d.d.d.d
+            case '.':
+                numberOfPeriods++;
+                if (numberOfPeriods > 3) {
                     return false;
                 }
-				if (!isValidIP4Word(word)) {
+                if (!isValidIP4Word(word)) {
                     return false;
                 }
-				if (numberOfColons != 6 && !doubleColon) {
+                if (numberOfColons != 6 && !doubleColon) {
                     return false;
                 }
-				// a special case ::1:2:3:4:5:d.d.d.d allows 7 colons with an
-				// IPv4 ending, otherwise 7 :'s is bad
-				if (numberOfColons == 7 && ipAddress.charAt(0 + offset) != ':'
-						&& ipAddress.charAt(1 + offset) != ':') {
+                // a special case ::1:2:3:4:5:d.d.d.d allows 7 colons with an
+                // IPv4 ending, otherwise 7 :'s is bad
+                if (numberOfColons == 7 && ipAddress.charAt(0 + offset) != ':'
+                        && ipAddress.charAt(1 + offset) != ':') {
                     return false;
                 }
-				word = "";
-				break;
+                word = "";
+                break;
 
-			case ':':
-				numberOfColons++;
-				if (numberOfColons > 7) {
+            case ':':
+                numberOfColons++;
+                if (numberOfColons > 7) {
                     return false;
                 }
-				if (numberOfPeriods > 0) {
+                if (numberOfPeriods > 0) {
                     return false;
                 }
-				if (prevChar == ':') {
-					if (doubleColon) {
+                if (prevChar == ':') {
+                    if (doubleColon) {
                         return false;
                     }
-					doubleColon = true;
-				}
-				word = "";
-				break;
-			case '%':
-				if (numberOfColons == 0) {
-                    return false;
-                }
-				numberOfPercent++;
-
-				// validate that the stuff after the % is valid
-				if ((i + 1) >= length) {
-					// in this case the percent is there but no number is
-					// available
-					return false;
-				}
-				try {
-					Integer.parseInt(ipAddress.substring(i + 1));
-				} catch (NumberFormatException e) {
-					// right now we just support an integer after the % so if
-					// this is not
-					// what is there then return
-					return false;
-				}
-				break;
-
-			default:
-				if (numberOfPercent == 0) {
-					if (word.length() > 3) {
+                    doubleColon = true;
+                }
+                word = "";
+                break;
+            case '%':
+                if (numberOfColons == 0) {
+                    return false;
+                }
+                numberOfPercent++;
+
+                // validate that the stuff after the % is valid
+                if ((i + 1) >= length) {
+                    // in this case the percent is there but no number is
+                    // available
+                    return false;
+                }
+                try {
+                    Integer.parseInt(ipAddress.substring(i + 1));
+                } catch (NumberFormatException e) {
+                    // right now we just support an integer after the % so if
+                    // this is not
+                    // what is there then return
+                    return false;
+                }
+                break;
+
+            default:
+                if (numberOfPercent == 0) {
+                    if (word.length() > 3) {
                         return false;
                     }
-					if (!isValidHexChar(c)) {
+                    if (!isValidHexChar(c)) {
                         return false;
                     }
-				}
-				word += c;
-			}
-		}
-
-		// Check if we have an IPv4 ending
-		if (numberOfPeriods > 0) {
-			if (numberOfPeriods != 3 || !isValidIP4Word(word)) {
+                }
+                word += c;
+            }
+        }
+
+        // Check if we have an IPv4 ending
+        if (numberOfPeriods > 0) {
+            if (numberOfPeriods != 3 || !isValidIP4Word(word)) {
+                return false;
+            }
+        } else {
+            // If we're at then end and we haven't had 7 colons then there is a
+            // problem unless we encountered a doubleColon
+            if (numberOfColons != 7 && !doubleColon) {
                 return false;
             }
-		} else {
-			// If we're at then end and we haven't had 7 colons then there is a
-			// problem unless we encountered a doubleColon
-			if (numberOfColons != 7 && !doubleColon) {
-				return false;
-			}
-
-			// If we have an empty word at the end, it means we ended in either
-			// a : or a .
-			// If we did not end in :: then this is invalid
-			if (numberOfPercent == 0) {
-				if (word == "" && ipAddress.charAt(length - 1 - offset) == ':'
-						&& ipAddress.charAt(length - 2 - offset) != ':') {
-					return false;
-				}
-			}
-		}
-
-		return true;
-	}
-
-	public static boolean isValidIP4Word(String word) {
-		char c;
-		if (word.length() < 1 || word.length() > 3) {
+
+            // If we have an empty word at the end, it means we ended in either
+            // a : or a .
+            // If we did not end in :: then this is invalid
+            if (numberOfPercent == 0) {
+                if (word == "" && ipAddress.charAt(length - 1 - offset) == ':'
+                        && ipAddress.charAt(length - 2 - offset) != ':') {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean isValidIP4Word(String word) {
+        char c;
+        if (word.length() < 1 || word.length() > 3) {
             return false;
         }
-		for (int i = 0; i < word.length(); i++) {
-			c = word.charAt(i);
-			if (!(c >= '0' && c <= '9')) {
+        for (int i = 0; i < word.length(); i++) {
+            c = word.charAt(i);
+            if (!(c >= '0' && c <= '9')) {
                 return false;
             }
-		}
-		if (Integer.parseInt(word) > 255) {
+        }
+        if (Integer.parseInt(word) > 255) {
             return false;
         }
-		return true;
-	}
+        return true;
+    }
 
-	static boolean isValidHexChar(char c) {
+    static boolean isValidHexChar(char c) {
 
-		return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')
-				|| (c >= 'a' && c <= 'f');
-	}
-
-	/**
-	 * Takes a string and parses it to see if it is a valid IPV4 address.
-	 * 
-	 * @return true, if the string represents an IPV4 address in dotted
-	 *         notation, false otherwise
-	 */
-	public static boolean isValidIPV4Address(String value) {
+        return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')
+                || (c >= 'a' && c <= 'f');
+    }
+
+    /**
+     * Takes a string and parses it to see if it is a valid IPV4 address.
+     * 
+     * @return true, if the string represents an IPV4 address in dotted
+     *         notation, false otherwise
+     */
+    public static boolean isValidIPV4Address(String value) {
         // general test
         if (!value.matches("[\\p{Digit}\\.]*")) {
             return false;
@@ -500,6 +513,6 @@ public class Inet6Util {
             }
         }
         return true;
-	}
+    }
 
 }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java
Wed May 19 10:56:01 2010
@@ -22,6 +22,7 @@ import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.net.UnknownHostException;
+import java.util.Locale;
 
 import org.apache.harmony.testframework.serialization.SerializationTest;
 import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
@@ -822,6 +823,16 @@ public class Inet6AddressTest extends ju
 		Inet6Address.getByAddress("123", addr2, nif);
 	}
 
+    public void test_getHostAddress_() throws Exception {
+        byte[] ipAddress = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+        InetAddress ia = InetAddress.getByAddress(ipAddress);
+        assertEquals("0:0:0:0:0:0:0:1", ia.getHostAddress().toLowerCase(Locale.US));
+
+        ipAddress = new byte[] {-2, -128, 0, 0, 0, 0, 0, 0, 2, 17, 37, -1, -2, -8, 124, -79};
+        ia = InetAddress.getByAddress(ipAddress);
+        assertEquals("fe80:0:0:0:211:25ff:fef8:7cb1", ia.getHostAddress().toLowerCase(Locale.US));
+    }
+
 	/**
 	 * @throws UnknownHostException
 	 * @tests java.net.Inet6Address#getScopeID()

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
Wed May 19 10:56:01 2010
@@ -1006,6 +1006,47 @@ class SocketChannelImpl extends SocketCh
             return new SocketChannelInputStream(channel);
         }
 
+        @Override
+        public InetAddress getInetAddress() {
+            if (channel.connectAddress == null && super.getInetAddress() != null)
{
+                channel.connectAddress = new InetSocketAddress(super.getInetAddress(), super.getPort());
+            }
+            if (channel.connectAddress == null) {
+                return null;
+            }
+            return channel.connectAddress.getAddress();
+        }
+
+        @Override
+        public SocketAddress getRemoteSocketAddress() {
+            if (channel.connectAddress == null && super.getInetAddress() != null)
{
+                channel.connectAddress = new InetSocketAddress(super.getInetAddress(), super.getPort());
+            }
+            return channel.connectAddress;
+        }
+
+        @Override
+        public int getPort() {
+            if (channel.connectAddress == null && super.getInetAddress() != null)
{
+                channel.connectAddress = new InetSocketAddress(super.getInetAddress(), super.getPort());
+            }
+            if (channel.connectAddress == null) {
+                return 0;
+            }
+            return channel.connectAddress.getPort();
+        }
+
+        @Override
+        public int getLocalPort() {
+            if (!isBound()) {
+                return -1;
+            }
+            if (channel.localPort == 0 && super.getLocalPort() != -1) {
+                channel.localPort = super.getLocalPort();
+            }
+            return channel.localPort;
+        }
+
         /*
          * Checks whether the channel is open.
          */

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java?rev=946120&r1=946119&r2=946120&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
Wed May 19 10:56:01 2010
@@ -369,6 +369,63 @@ public class SocketChannelTest extends T
         }
     }
 
+    public void testSocket_getInetAddress() throws Exception {
+        Socket socket = channel1.socket();
+        assertNull(socket.getInetAddress());
+
+        channel1.connect(localAddr1);
+
+        assertNotNull(socket.getInetAddress());
+        assertEquals(localAddr1.getAddress(), socket.getInetAddress());
+    }
+
+    public void testSocket_getRemoteSocketAddress() throws Exception {
+        Socket socket = channel1.socket();
+        assertNull(socket.getRemoteSocketAddress());
+
+        channel1.connect(localAddr1);
+
+        assertNotNull(socket.getRemoteSocketAddress());
+        assertEquals(localAddr1, socket.getRemoteSocketAddress());
+    }
+
+    public void testSocket_getPort() throws Exception {
+        Socket socket = channel1.socket();
+        assertEquals(0, socket.getPort());
+
+        channel1.connect(localAddr1);
+
+        assertEquals(localAddr1.getPort(), socket.getPort());
+    }
+
+    public void testSocket_getLocalAddress() throws Exception {
+        Socket socket = channel1.socket();
+        assertNotNull(socket.getLocalAddress());
+
+        channel1.connect(localAddr1);
+
+        assertNotNull(socket.getLocalAddress());
+    }
+
+    public void testSocket_getLocalSocketAddress() throws Exception {
+        Socket socket = channel1.socket();
+        assertNull(socket.getLocalSocketAddress());
+
+        channel1.connect(localAddr1);
+
+        assertNotNull(socket.getLocalSocketAddress());
+    }
+
+    public void testSocket_getLocalPort() throws Exception {
+        Socket socket = channel1.socket();
+        assertEquals(-1, socket.getLocalPort());
+
+        channel1.connect(localAddr1);
+
+        assertTrue(-1 != socket.getLocalPort());
+        assertTrue(0 != socket.getLocalPort());
+    }
+
     private void assertSocketBeforeConnect(Socket s) throws IOException {
         assertFalse(s.isBound());
         assertFalse(s.isClosed());

Propchange: harmony/enhanced/java/branches/java6/common_resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 19 10:56:01 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh/common_resources:935751-941490
-/harmony/enhanced/java/trunk/common_resources:929253-943968
+/harmony/enhanced/java/trunk/common_resources:929253-945584
 /harmony/enhanced/trunk/common_resources:476396-929252
 /incubator/harmony/enhanced/trunk/common_resources:423974-476394

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 19 10:56:01 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-943968
+/harmony/enhanced/java/trunk/drlvm:929253-945584
 /harmony/enhanced/trunk/drlvm:810871-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/working_vm:423974-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 19 10:56:01 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-943968
+/harmony/enhanced/java/trunk/jdktools:929253-945584
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:810871-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message