Exemple #1
0
 /** Return atom as a string literal */
 @Pure
 public synchronized String toUnicodeString() throws java.io.UTFDataFormatException {
   if (unicodeStringOrJTOCoffset == null) {
     String s = UTF8Convert.fromUTF8(val);
     if (VM.runningVM) {
       s = InternedStrings.internUnfoundString(s);
       unicodeStringOrJTOCoffset = s;
     } else if (!VM.writingImage) {
       s = s.intern();
       int offset = Statics.findOrCreateObjectLiteral(s);
       unicodeStringOrJTOCoffset = offset;
     }
     return s;
   } else if (unicodeStringOrJTOCoffset instanceof String) {
     return (String) unicodeStringOrJTOCoffset;
   } else {
     if (VM.runningVM) {
       return (String)
           Statics.getSlotContentsAsObject(
               Offset.fromIntSignExtend((Integer) unicodeStringOrJTOCoffset));
     } else {
       return UTF8Convert.fromUTF8(val).intern();
     }
   }
 }
Exemple #2
0
 /** Atom as string literal or null if atom hasn't been converted */
 private synchronized String toUnicodeStringInternal() {
   if (unicodeStringOrJTOCoffset == null) {
     return null;
   } else if (unicodeStringOrJTOCoffset instanceof String) {
     return (String) unicodeStringOrJTOCoffset;
   } else {
     if (VM.runningVM) {
       Object result =
           Statics.getSlotContentsAsObject(
               Offset.fromIntSignExtend((Integer) unicodeStringOrJTOCoffset));
       return (String) result;
     } else {
       try {
         return UTF8Convert.fromUTF8(val).intern();
       } catch (UTFDataFormatException e) {
         throw new Error("Error in UTF data encoding: ", e);
       }
     }
   }
 }