Use 'a' operand code for prefetch instruction.
[official-gcc.git] / libjava / java / rmi / server / RemoteObject.java
blob6f12866919145a1dc75499881e3aae035d336036
1 /*
2 Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License.
28 package java.rmi.server;
30 import java.io.Serializable;
31 import java.rmi.Remote;
32 import java.rmi.NoSuchObjectException;
33 import java.rmi.UnmarshalException;
34 import java.rmi.server.RemoteRef;
35 import java.io.ObjectInputStream;
36 import java.io.ObjectOutputStream;
37 import java.io.IOException;
38 import java.lang.ClassNotFoundException;
39 import java.lang.InstantiationException;
40 import java.lang.IllegalAccessException;
42 public abstract class RemoteObject
43 implements Remote, Serializable {
45 public static final long serialVersionUID = -3215090123894869218l;
47 protected transient RemoteRef ref;
49 protected RemoteObject() {
50 this(null);
53 protected RemoteObject(RemoteRef newref) {
54 ref = newref;
57 public RemoteRef getRef() {
58 return (ref);
61 public static Remote toStub(Remote obj) throws NoSuchObjectException {
62 throw new Error("Not implemented");
65 public int hashCode() {
66 if (ref == null) {
67 return (0);
69 else {
70 return (ref.hashCode());
74 public boolean equals(Object obj) {
75 // We only compare references.
76 return (this == obj);
79 public String toString() {
80 return (ref.toString());
83 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
84 String cname = in.readUTF();
85 if (!cname.equals("")) {
86 cname = RemoteRef.packagePrefix + '.' + cname;
87 try {
88 Class cls = Class.forName(cname);
89 ref = (RemoteRef)cls.newInstance();
91 catch (InstantiationException e1) {
92 throw new UnmarshalException("failed to create ref");
94 catch (IllegalAccessException e2) {
95 throw new UnmarshalException("failed to create ref");
97 ref.readExternal(in);
99 else {
100 ref = (RemoteRef)in.readObject();
104 private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException {
105 if (ref == null) {
106 throw new UnmarshalException("no ref to serialize");
108 String cname = ref.getRefClass(out);
109 if (cname != null && cname.length() > 0) {
110 out.writeUTF(cname);
111 ref.writeExternal(out);
113 else {
114 out.writeUTF("");
115 out.writeObject(ref);