harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r825865 - in /harmony/enhanced/classlib/trunk/modules/lang-management: make/findbugs-exclude-filter.xml src/main/java/java/lang/management/MemoryType.java src/main/java/org/apache/harmony/lang/management/ManagementUtils.java
Date Fri, 16 Oct 2009 12:27:17 GMT
Author: odeakin
Date: Fri Oct 16 12:27:17 2009
New Revision: 825865

URL: http://svn.apache.org/viewvc?rev=825865&view=rev
Log:
Commit patch for HARMONY-6356 ([classlib][lang-managment] Improvements to lang-management
classes from findbugs)

Added:
    harmony/enhanced/classlib/trunk/modules/lang-management/make/findbugs-exclude-filter.xml
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/java/lang/management/MemoryType.java
    harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/org/apache/harmony/lang/management/ManagementUtils.java

Added: harmony/enhanced/classlib/trunk/modules/lang-management/make/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/lang-management/make/findbugs-exclude-filter.xml?rev=825865&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/lang-management/make/findbugs-exclude-filter.xml
(added)
+++ harmony/enhanced/classlib/trunk/modules/lang-management/make/findbugs-exclude-filter.xml
Fri Oct 16 12:27:17 2009
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements. See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You under the Apache License, Version
+        2.0 (the "License"); you may not use this file except in compliance
+        with the License. You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+        applicable law or agreed to in writing, software distributed under the
+        License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+        CONDITIONS OF ANY KIND, either express or implied. See the License for
+        the specific language governing permissions and limitations under the
+        License.
+    -->
+
+    <!-- Exclusion filter for running FindBugs against Apache Harmony -->
+
+    <!--
+        Format and code information is available here
+        http://findbugs.sourceforge.net/manual/filter.html
+    -->
+<FindBugsFilter>
+    <!-- RI exposes mutable StackTraceElement[] object also -->
+    <Match>
+        <Class name="java.lang.management.ThreadInfo" />
+        <Method name="getStackTrace" />
+        <Bug pattern="EI_EXPOSE_REP" />
+    </Match>
+</FindBugsFilter>

Propchange: harmony/enhanced/classlib/trunk/modules/lang-management/make/findbugs-exclude-filter.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/java/lang/management/MemoryType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/java/lang/management/MemoryType.java?rev=825865&r1=825864&r2=825865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/java/lang/management/MemoryType.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/java/lang/management/MemoryType.java
Fri Oct 16 12:27:17 2009
@@ -30,25 +30,17 @@
      * Heap memory type.
      * </p>
      */
-    HEAP,
+    HEAP {
+        @Override
+        public String toString() { return "Heap memory"; }
+    },
     /**
      * <p>
      * Non-heap memory type.
      * </p>
      */
-    NON_HEAP;
-
-    @Override
-    public String toString() {
-        String result = null;
-        switch (this) {
-            case HEAP:
-                result = "Heap memory";
-                break;
-            case NON_HEAP:
-                result = "Non-heap memory";
-                break;
-        }
-        return result;
-    }
+    NON_HEAP {
+        @Override
+        public String toString() { return "Non-heap memory"; }
+    };
 }

Modified: harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/org/apache/harmony/lang/management/ManagementUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/org/apache/harmony/lang/management/ManagementUtils.java?rev=825865&r1=825864&r2=825865&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/org/apache/harmony/lang/management/ManagementUtils.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/lang-management/src/main/java/org/apache/harmony/lang/management/ManagementUtils.java
Fri Oct 16 12:27:17 2009
@@ -853,9 +853,10 @@
 
         CompositeData result = null;
         String[] names = { "init", "used", "committed", "max" };
-        Object[] values = { new Long(usage.getInit()),
-                new Long(usage.getUsed()), new Long(usage.getCommitted()),
-                new Long(usage.getMax()) };
+        Object[] values = { Long.valueOf(usage.getInit()),
+                Long.valueOf(usage.getUsed()),
+                Long.valueOf(usage.getCommitted()),
+                Long.valueOf(usage.getMax()) };
         CompositeType cType = getMemoryUsageCompositeType();
         try {
             result = new CompositeDataSupport(cType, names, values);
@@ -905,9 +906,9 @@
 
         CompositeData result = null;
         String[] names = { "poolName", "usage", "count" };
-        Object[] values = { new String(info.getPoolName()),
+        Object[] values = { info.getPoolName(),
                 toMemoryUsageCompositeData(info.getUsage()),
-                new Long(info.getCount()) };
+                Long.valueOf(info.getCount()) };
         CompositeType cType = getMemoryNotificationInfoCompositeType();
         try {
             result = new CompositeDataSupport(cType, names, values);
@@ -967,20 +968,19 @@
                 "waitedCount", "waitedTime", "lockName", "lockOwnerId",
                 "lockOwnerName", "stackTrace" };
         Object[] values = {
-                new Long(info.getThreadId()),
-                new String(info.getThreadName()),
-                new String(info.getThreadState().name()),
-                new Boolean(info.isSuspended()),
-                new Boolean(info.isInNative()),
-                new Long(info.getBlockedCount()),
-                new Long(info.getBlockedTime()),
-                new Long(info.getWaitedCount()),
-                new Long(info.getWaitedTime()),
-                info.getLockName() != null ? new String(info.getLockName())
-                        : null,
-                new Long(info.getLockOwnerId()),
-                info.getLockOwnerName() != null ? new String(info
-                        .getLockOwnerName()) : null, stArray };
+                Long.valueOf(info.getThreadId()),
+                info.getThreadName(),
+                info.getThreadState().name(),
+                Boolean.valueOf(info.isSuspended()),
+                Boolean.valueOf(info.isInNative()),
+                Long.valueOf(info.getBlockedCount()),
+                Long.valueOf(info.getBlockedTime()),
+                Long.valueOf(info.getWaitedCount()),
+                Long.valueOf(info.getWaitedTime()),
+                info.getLockName(),
+                Long.valueOf(info.getLockOwnerId()),
+                info.getLockOwnerName(), 
+                stArray };
         CompositeType cType = getThreadInfoCompositeType();
         try {
             result = new CompositeDataSupport(cType, names, values);
@@ -1011,12 +1011,12 @@
 
         // A file name of null is permissable
         String fileName = element.getFileName();
-        String fileNameValue = (fileName == null) ? null : new String(fileName);
 
-        Object[] values = { new String(element.getClassName()),
-                new String(element.getMethodName()), fileNameValue,
-                new Integer(element.getLineNumber()),
-                new Boolean(element.isNativeMethod()) };
+        Object[] values = { element.getClassName(),
+                element.getMethodName(), 
+                fileName,
+                Integer.valueOf(element.getLineNumber()),
+                Boolean.valueOf(element.isNativeMethod()) };
         CompositeType cType = getStackTraceElementCompositeType();
         try {
             result = new CompositeDataSupport(cType, names, values);
@@ -1401,12 +1401,11 @@
 
             // Take each entry out of the input propsMap, put it into a new
             // instance of CompositeData and put into the TabularType
-            Set<String> keys = propsMap.keySet();
-            for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
-                String propKey = iter.next();
-                String propVal = propsMap.get(propKey);
+            Set<Map.Entry<String,String>> entrySet = propsMap.entrySet();
+            for (Iterator<Map.Entry<String, String>> iter = entrySet.iterator();
iter.hasNext();) {
+                Map.Entry<String,String> entry = iter.next();
                 result.put(new CompositeDataSupport(rowType, rtItemNames,
-                        new String[] { propKey, propVal }));
+                        new String[] { entry.getKey(), entry.getValue() }));
             }// end for
         } catch (OpenDataException e) {
             if (ManagementUtils.VERBOSE_MODE) {



Mime
View raw message