1 // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
5 import org.ibex.util.*;
7 import java.security.*;
8 import java.security.cert.*;
9 import org.ibex.graphics.*;
10 import org.ibex.core.*;
11 import org.ibex.net.*;
13 /** common superclass for all platforms that use GCJ to compile a native binary */
14 public abstract class GCJ extends Platform {
16 protected native InputStream _getBuiltinInputStream();
18 protected native void _decodeJPEG(InputStream is, Picture p);
20 // FEATURE: This could be optimized (a lot) by using a custom hashtable
21 public final static class Retainer {
22 private static Hash table = new Hash();
23 private final static class Key {
25 public Key(Object o) { this.o = o; }
26 public int hashCode() { return o == null ? 0 : o.hashCode(); }
27 public boolean equals(Object o2) { return (o2 instanceof Key) && ((Key)o2).o == o; }
29 private final static class Entry {
31 public Entry() { inc(); }
32 public void inc() { refCount++; }
33 public boolean dec() { return --refCount == 0; }
35 public static synchronized void retain(Object o) {
37 Entry r = (Entry) table.get(k);
38 if(r == null) table.put(k,new Entry());
41 public static synchronized void release(Object o) {
43 Entry e = (Entry) table.get(k);
44 if(e == null) throw new Error("Retainer::Release on unknown object");
45 if(e.dec()) { table.remove(k); }