summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WobClassLoader.java
blob: 2ce876ba733893cceb2cd816cf838d93ec68df21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.InputStream;
/*     */ import java.util.Hashtable;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WobClassLoader
/*     */   extends ClassLoader
/*     */ {
/*  28 */   static Hashtable<String, WobClassLoader> loaders = new Hashtable();
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static synchronized Class<?> get(String zipName, String cname)
/*     */   {
/*  41 */     WobClassLoader cl = (WobClassLoader)loaders.get(zipName);
/*     */     
/*  43 */     if (cl == null) {
/*  44 */       cl = new WobClassLoader(zipName);
/*  45 */       loaders.put(zipName, cl);
/*     */     }
/*     */     try
/*     */     {
/*  49 */       return cl.loadClass(cname, true);
/*     */     } catch (ClassNotFoundException e) {}
/*  51 */     return null;
/*     */   }
/*     */   
/*     */ 
/*  55 */   Hashtable<String, Class<?>> classes = new Hashtable();
/*     */   String zipName;
/*     */   
/*     */   public WobClassLoader(String n) {
/*  59 */     this.zipName = n;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected synchronized Class<?> loadClass(String cname, boolean resolve)
/*     */     throws ClassNotFoundException
/*     */   {
/*  68 */     Class<?> cl = (Class)this.classes.get(cname);
/*  69 */     if (cl == null)
/*     */     {
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */       try
/*     */       {
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  82 */         return findSystemClass(cname);
/*     */       }
/*     */       catch (NoClassDefFoundError localNoClassDefFoundError) {}catch (ClassNotFoundException localClassNotFoundException) {}
/*     */       
/*  86 */       byte[] data = loadData(cname);
/*  87 */       if (data != null) {
/*     */         try {
/*  89 */           cl = defineClass(null, data, 0, data.length);
/*     */         } catch (ClassFormatError e) {
/*  91 */           throw new ClassNotFoundException(cname);
/*     */         }
/*     */       }
/*     */       
/*  95 */       if ((cl == null) || (!cname.equals(cl.getName()))) {
/*  96 */         throw new ClassNotFoundException(cname);
/*     */       }
/*  98 */       this.classes.put(cname, cl);
/*     */     }
/* 100 */     if (resolve)
/* 101 */       resolveClass(cl);
/* 102 */     return cl;
/*     */   }
/*     */   
/*     */ 
/*     */   private byte[] loadData(String cname)
/*     */   {
/* 108 */     byte[] data = null;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 114 */     InputStream in = null;
/*     */     try {
/* 116 */       if (cname != null) {
/* 117 */         File file = new File(this.zipName);
/* 118 */         int len = (int)file.length();
/* 119 */         in = new FileInputStream(file);
/*     */         
/* 121 */         data = new byte[len];
/* 122 */         if (in.read(data) == len) {
/* 123 */           return data;
/*     */         }
/*     */       }
/*     */     } catch (Exception localException1) {}finally {
/* 127 */       if (in != null) {
/* 128 */         try { in.close();
/*     */         }
/*     */         catch (Exception localException3) {}
/*     */       }
/*     */     }
/* 127 */     if (in != null)
/* 128 */       try { in.close();
/*     */       } catch (Exception localException4) {}
/* 130 */     return null;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WobClassLoader.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */