hotspot/src/share/vm/classfile/vmSymbols.cpp
changeset 12263 d20640f4f8fe
parent 8675 e9fef2a9bef7
child 13391 30245956af37
equal deleted inserted replaced
12262:fb3b9fede660 12263:d20640f4f8fe
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    77   assert(vmIntrinsics::FLAG_LIMIT <= (1 << vmIntrinsics::log2_FLAG_LIMIT), "must fit in this bitfield");
    77   assert(vmIntrinsics::FLAG_LIMIT <= (1 << vmIntrinsics::log2_FLAG_LIMIT), "must fit in this bitfield");
    78 
    78 
    79   if (!UseSharedSpaces) {
    79   if (!UseSharedSpaces) {
    80     const char* string = &vm_symbol_bodies[0];
    80     const char* string = &vm_symbol_bodies[0];
    81     for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
    81     for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
    82       Symbol* sym = SymbolTable::new_symbol(string, CHECK);
    82       Symbol* sym = SymbolTable::new_permanent_symbol(string, CHECK);
    83       _symbols[index] = sym;
    83       _symbols[index] = sym;
    84       string += strlen(string); // skip string body
    84       string += strlen(string); // skip string body
    85       string += 1;              // skip trailing null
    85       string += 1;              // skip trailing null
    86     }
    86     }
    87 
    87 
   126 #ifdef ASSERT
   126 #ifdef ASSERT
   127   {
   127   {
   128     // Spot-check correspondence between strings, symbols, and enums:
   128     // Spot-check correspondence between strings, symbols, and enums:
   129     assert(_symbols[NO_SID] == NULL, "must be");
   129     assert(_symbols[NO_SID] == NULL, "must be");
   130     const char* str = "java/lang/Object";
   130     const char* str = "java/lang/Object";
   131     TempNewSymbol jlo = SymbolTable::new_symbol(str, CHECK);
   131     TempNewSymbol jlo = SymbolTable::new_permanent_symbol(str, CHECK);
   132     assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, "");
   132     assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, "");
   133     assert(jlo == java_lang_Object(), "");
   133     assert(jlo == java_lang_Object(), "");
   134     SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object);
   134     SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object);
   135     assert(find_sid(jlo) == sid, "");
   135     assert(find_sid(jlo) == sid, "");
   136     assert(symbol_at(sid) == jlo, "");
   136     assert(symbol_at(sid) == jlo, "");
   145     }
   145     }
   146 
   146 
   147     // The string "format" happens (at the moment) not to be a vmSymbol,
   147     // The string "format" happens (at the moment) not to be a vmSymbol,
   148     // though it is a method name in java.lang.String.
   148     // though it is a method name in java.lang.String.
   149     str = "format";
   149     str = "format";
   150     TempNewSymbol fmt = SymbolTable::new_symbol(str, CHECK);
   150     TempNewSymbol fmt = SymbolTable::new_permanent_symbol(str, CHECK);
   151     sid = find_sid(fmt);
   151     sid = find_sid(fmt);
   152     assert(sid == NO_SID, "symbol index works (negative test)");
   152     assert(sid == NO_SID, "symbol index works (negative test)");
   153   }
   153   }
   154 #endif
   154 #endif
   155 }
   155 }