harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r419541 - in /incubator/harmony/enhanced/drlvm/trunk/vm: tests/smoke/util/ vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/ vmcore/src/kernel_classes/native/
Date Thu, 06 Jul 2006 12:57:45 GMT
Author: geirm
Date: Thu Jul  6 05:57:44 2006
New Revision: 419541

URL: http://svn.apache.org/viewvc?rev=419541&view=rev
Log:
Patches from HARMONY-721

Fix to restore String.intern() via fix to VM kernel
class after removal of String class.

Also added a testcase for String interning.



Added:
    incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/util/StringIntern.java
Removed:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_String.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_String.h
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.h

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/util/StringIntern.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/util/StringIntern.java?rev=419541&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/util/StringIntern.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/util/StringIntern.java Thu Jul 
6 05:57:44 2006
@@ -0,0 +1,38 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.
+ */
+
+package util;
+
+/**
+ * Tests the correctness of string interning.
+ *
+ */
+public class StringIntern {
+    public static void main(String[] args) {
+        String s = "abcde";
+        String s0 = "abcde".intern();
+        String s1 = ("abc" + "de").intern();
+        String s2 = ("ab" + "cde").intern();
+
+        if (s0 != s1 || s1 != s2) {
+            System.out.println("FAIL: incorrect interning");
+        } else if (s != s0) {
+            System.out.println("FAIL: literal is not interned");
+        } else {
+            System.out.println("PASS");
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java?rev=419541&r1=419540&r2=419541&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java
Thu Jul  6 05:57:44 2006
@@ -114,4 +114,21 @@
         	Runtime.getRuntime().addShutdownHook(new Thread(new DeleteOnExitHook()));
     	}
     }
+    
+    /**
+     *  Returns an intern-ed representation of the 
+     *  String
+     *  
+     *  @param s string to be interned
+     *  @return String that has the same contents as 
+     *    argument, but from internal pool
+     */
+    public static String intern(String s) {
+        return intern0(s);
+    }
+    
+    /**
+     * Invokes native string interning service.
+     */
+    private static native String intern0(String s);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp?rev=419541&r1=419540&r2=419541&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp
Thu Jul  6 05:57:44 2006
@@ -13,11 +13,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Euguene Ostrovsky
- * @version $Revision: 1.1.2.1.4.6 $
- */
-
 /**
  * @file org_apache_harmony_kernel_vm_VM.cpp
  *
@@ -31,6 +26,7 @@
 #define LOG_DOMAIN "vm.accessors"
 #include "jni_utils.h"
 
+#include "vm_strings.h"
 #include "org_apache_harmony_kernel_vm_VM.h"
 #include "java_lang_VMClassRegistry.h"
 
@@ -43,4 +39,15 @@
 {
     // reuse similar method in VMClassRegistry
     return Java_java_lang_VMClassRegistry_getClassLoader(jenv, NULL, clazz);
+}
+
+/**
+ * Implements org.apache.harmony.vm.VM.intern0(..) method.
+ * For details see kernel classes component documentation.
+ */
+JNIEXPORT jstring JNICALL
+Java_org_apache_harmony_kernel_vm_VM_intern0(JNIEnv *jenv, jclass, jstring str)
+{
+    // call corresponding VM internal function
+    return string_intern(jenv, str);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.h?rev=419541&r1=419540&r2=419541&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.h
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.h
Thu Jul  6 05:57:44 2006
@@ -14,11 +14,6 @@
  *  limitations under the License.
  */
 
-/** 
- * @author Euguene Ostrovsky
- * @version $Revision: 1.1.2.1.4.6 $
- */  
-
 /*
  * THE FILE HAS BEEN AUTOGENERATED BY INTEL IJH TOOL.
  * Please be aware that all changes made to this file manually
@@ -47,10 +42,16 @@
 Java_org_apache_harmony_kernel_vm_VM_getClassLoader(JNIEnv *, jclass, 
     jclass);
 
+/*
+ * Method: org.apache.harmony.kernel.vm.VM.intern0()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_org_apache_harmony_kernel_vm_VM_intern0(JNIEnv *, jclass, jstring);
+
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _COM_IBM_OTI_VM_VM_H */
+#endif /* _ORG_APACHE_HARMONY_KERNEL_VM_VM_H */
 



Mime
View raw message