01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
21:
22: /**
23: * Represents bytecode for a cached class.
24: */
25: public class ByteCode implements Serializable {
26:
27: private static final String systemString = System.getProperty(
28: "java.class.path", ".");
29:
30: private static final String 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 getCurrentSystemIdentifier() {
41: return systemStringAsIdentifier;
42: }
43:
44: private final String binaryTypeName;
45:
46: private final byte[] bytes;
47:
48: private final String location;
49:
50: private final String version;
51:
52: private final boolean isTransient;
53:
54: /**
55: * Specifies the bytecode for a given type.
56: */
57: public ByteCode(String binaryTypeName, byte[] bytes,
58: String location, 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 getBinaryTypeName() {
67: return binaryTypeName;
68: }
69:
70: public byte[] getBytes() {
71: return bytes;
72: }
73:
74: public String getLocation() {
75: return location;
76: }
77:
78: public String 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: }
|