01: //
02: // Copyright (C) 2005 United States Government as represented by the
03: // Administrator of the National Aeronautics and Space Administration
04: // (NASA). All Rights Reserved.
05: //
06: // This software is distributed under the NASA Open Source Agreement
07: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
08: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
09: // directory tree for the complete NOSA document.
10: //
11: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18: //
19:
20: package gov.nasa.jpf.jvm;
21:
22: /**
23: * MJI NativePeer class for java.lang.String library abstraction
24: */
25: public class JPF_java_lang_String {
26: public static int intern__(MJIEnv env, int robj) {
27: // now this is REALLY a naive implementation of 'intern', but
28: // at least we don't burn state for a Hashtable.
29: // Replace this once we have a real String abstraction
30: DynamicArea da = env.getDynamicArea();
31: ElementInfo sei = da.get(robj);
32: ElementInfo[] elems = da.elements;
33:
34: // <2do> really? with heap symmetry, can't a corresponding one be at > robj?
35: for (int i = 0; i < robj; i++) {
36: ElementInfo ei = elems[i];
37:
38: if (ei != null) {
39: if (ei.equals(sei)) {
40: return i;
41: }
42: }
43: }
44:
45: return robj;
46: }
47: }
|