src/share/vm/oops/constantPool.hpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -71,10 +71,13 @@
 class ConstantPool : public Metadata {
   friend class VMStructs;
   friend class BytecodeInterpreter;  // Directly extracts a klass in the pool for fast instanceof/checkcast
   friend class Universe;             // For null constructor
  private:
+  static const char* CPH_STR;
+  static const int   CPH_LEN;
+ private:
   Array<u1>*           _tags;        // the tag array describing the constant pool's contents
   ConstantPoolCache*   _cache;       // the cache holding interpreter runtime information
   InstanceKlass*       _pool_holder; // the corresponding class
   Array<u2>*           _operands;    // for variable-sized (InvokeDynamic) nodes, usually empty
 

@@ -403,32 +406,31 @@
   // object into a CONSTANT_String entry of an anonymous class.
   // Method oops internally created for method handles may also
   // use pseudo-strings to link themselves to related metaobjects.
 
   bool is_pseudo_string_at(int which) {
-    // A pseudo string is a string that doesn't have a symbol in the cpSlot
-    return unresolved_string_at(which) == NULL;
+    char* utf8 = unresolved_string_at(which)->as_utf8();
+    return strlen(utf8) > CPH_LEN && strncmp(utf8, CPH_STR, CPH_LEN) == 0;
   }
 
   oop pseudo_string_at(int which, int obj_index) {
     assert(tag_at(which).is_string(), "Corrupted constant pool");
-    assert(unresolved_string_at(which) == NULL, "shouldn't have symbol");
+    assert(is_pseudo_string_at(which), "must be a pseudo-string");
     oop s = resolved_references()->obj_at(obj_index);
     return s;
   }
 
   oop pseudo_string_at(int which) {
     assert(tag_at(which).is_string(), "Corrupted constant pool");
-    assert(unresolved_string_at(which) == NULL, "shouldn't have symbol");
+    assert(is_pseudo_string_at(which), "must be a pseudo-string");
     int obj_index = cp_to_object_index(which);
     oop s = resolved_references()->obj_at(obj_index);
     return s;
   }
 
   void pseudo_string_at_put(int which, int obj_index, oop x) {
     assert(tag_at(which).is_string(), "Corrupted constant pool");
-    unresolved_string_at_put(which, NULL); // indicates patched string
     string_at_put(which, obj_index, x);    // this works just fine
   }
 
   // only called when we are sure a string entry is already resolved (via an
   // earlier string_at call.