KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > jdt > ByteCode


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.dev.jdt;
17
18 import com.google.gwt.dev.About;
19
20 import java.io.Serializable JavaDoc;
21
22 /**
23  * Represents bytecode for a cached class.
24  */

25 public class ByteCode implements Serializable JavaDoc {
26
27   private static final String JavaDoc systemString = System.getProperty(
28       "java.class.path", ".");
29
30   private static final String JavaDoc systemStringAsIdentifier = About.GWT_VERSION
31       + "_" + systemString.hashCode();
32
33   /**
34    * This method returns the current system identifier, used to detect changes
35    * in the environment that would make cached data unusable.
36    *
37    * @return the current system identifier, which is sensitive to classpath and
38    * os changes as well as GWT version changes
39    */

40   public static String JavaDoc getCurrentSystemIdentifier() {
41     return systemStringAsIdentifier;
42   }
43
44   private final String JavaDoc binaryTypeName;
45
46   private final byte[] bytes;
47
48   private final String JavaDoc location;
49
50   private final String JavaDoc version;
51
52   private final boolean isTransient;
53
54   /**
55    * Specifies the bytecode for a given type.
56    */

57   public ByteCode(String JavaDoc binaryTypeName, byte[] bytes, String JavaDoc location,
58       boolean isTransient) {
59     this.binaryTypeName = binaryTypeName;
60     this.bytes = bytes;
61     this.location = location;
62     this.version = systemStringAsIdentifier;
63     this.isTransient = isTransient;
64   }
65
66   public String JavaDoc getBinaryTypeName() {
67     return binaryTypeName;
68   }
69
70   public byte[] getBytes() {
71     return bytes;
72   }
73
74   public String JavaDoc getLocation() {
75     return location;
76   }
77
78   public String JavaDoc getSystemIdentifier() {
79     return version;
80   }
81
82   public boolean isTransient() {
83     return isTransient;
84   }
85
86   // We explicitly do not set serialVersionUID, as it is generated
87
// automatically, and is more sensitive to class file changes than if
88
// it were generated manually.
89
}
90
Popular Tags