View | Details | Raw Unified | Return to bug 40943
Collapse All | Expand All

(-)src/org/aspectj/weaver/bcel/BcelWeaver.java (-7 / +43 lines)
Lines 47-52 Link Here
47
    private Map  sourceJavaClasses = new HashMap();   /* String -> UnwovenClassFile */
47
    private Map  sourceJavaClasses = new HashMap();   /* String -> UnwovenClassFile */
48
    private List addedClasses      = new ArrayList(); /* List<UnovenClassFile> */
48
    private List addedClasses      = new ArrayList(); /* List<UnovenClassFile> */
49
    private List deletedTypenames  = new ArrayList(); /* List<String> */
49
    private List deletedTypenames  = new ArrayList(); /* List<String> */
50
    private Map resources          = new HashMap();   /* String -> byte[] */ 
50
    private boolean needToReweaveWorld = false;
51
    private boolean needToReweaveWorld = false;
51
52
52
    private List shadowMungerList = null; // setup by prepareForWeave
53
    private List shadowMungerList = null; // setup by prepareForWeave
Lines 119-138 Link Here
119
			ZipEntry entry = inStream.getNextEntry();
120
			ZipEntry entry = inStream.getNextEntry();
120
			if (entry == null) break;
121
			if (entry == null) break;
121
			
122
			
123
			byte[] bytes = FileUtil.readAsByteArray(inStream);
124
			String filename = entry.getName();
125
122
			if (entry.isDirectory() || !entry.getName().endsWith(".class")) {
126
			if (entry.isDirectory() || !entry.getName().endsWith(".class")) {
127
				System.out.println("? " + getClass().getName() + ".addJarFile() entry=" + entry);
128
				addResource(filename,bytes);
129
				
123
				continue; //??? need to pass other things along untouched
130
				continue; //??? need to pass other things along untouched
124
//				outStream.putNextEntry(entry);
131
//				outStream.putNextEntry(entry);
125
//				outStream.write(Utility.getByteArray(inStream));
132
//				outStream.write(Utility.getByteArray(inStream));
126
//				outStream.closeEntry();
133
//				outStream.closeEntry();
127
//				return;
134
//				return;
128
			}
135
			}
129
			//System.err.println("adding class: " + entry.getName());
136
			else {
130
		
137
				UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);
131
			byte[] bytes = FileUtil.readAsByteArray(inStream);
138
				inStream.closeEntry();
132
			String filename = entry.getName();
139
				this.addClassFile(classFile);
133
			UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);
140
				//System.err.println("adding class: " + entry.getName());
134
			inStream.closeEntry();
141
			}
135
			this.addClassFile(classFile);
142
			
136
		}
143
		}
137
		
144
		
138
		inStream.close();
145
		inStream.close();
Lines 154-159 Link Here
154
    	world.deleteSourceObjectType(TypeX.forName(typename));
161
    	world.deleteSourceObjectType(TypeX.forName(typename));
155
    }
162
    }
156
163
164
	public void addResource (String name, byte[] bytes) {
165
		resources.put(name,bytes);
166
	}
167
157
	// ---- weave preparation
168
	// ---- weave preparation
158
169
159
    public void prepareForWeave() {
170
    public void prepareForWeave() {
Lines 191-200 Link Here
191
    }
202
    }
192
    
203
    
193
    public void dumpUnwoven(File file) throws IOException {
204
    public void dumpUnwoven(File file) throws IOException {
205
		System.out.println("> " + getClass().getName() + ".dumpUnwoven(" + file + ")");
194
    	BufferedOutputStream os = FileUtil.makeOutputStream(file);
206
    	BufferedOutputStream os = FileUtil.makeOutputStream(file);
195
    	this.zipOutputStream = new ZipOutputStream(os);
207
    	this.zipOutputStream = new ZipOutputStream(os);
196
    	dumpUnwoven();
208
    	dumpUnwoven();
209
		/* BUG 40943*/
210
		dumpResources();
197
    	zipOutputStream.close();  //this flushes and closes the acutal file
211
    	zipOutputStream.close();  //this flushes and closes the acutal file
212
		System.out.println("< " + getClass().getName() + ".dumpUnwoven()");
198
    }
213
    }
199
    
214
    
200
    
215
    
Lines 206-223 Link Here
206
       	}
221
       	}
207
    }
222
    }
208
    
223
    
224
    /* BUG #40943 */
225
    public void dumpResources () throws IOException {
226
		System.out.println("> " + getClass().getName() + ".dumpResources()");
227
		
228
		Iterator iter = resources.keySet().iterator();
229
		while (iter.hasNext()) {
230
			String name = (String)iter.next();
231
			byte[] bytes = (byte[])resources.get(name);
232
			System.out.println(" " + getClass().getName() + ".dumpResources() " + name);
233
			writeZipEntry(name,bytes);
234
		}
235
		
236
		System.out.println("< " + getClass().getName() + ".dumpResources()");
237
    }
209
    
238
    
210
    // ---- weaving
239
    // ---- weaving
211
240
212
    public Collection weave(File file) throws IOException {
241
    public Collection weave(File file) throws IOException {
242
    	System.out.println("> " + getClass().getName() + ".weave(" + file + ")");
213
    	OutputStream os = FileUtil.makeOutputStream(file);
243
    	OutputStream os = FileUtil.makeOutputStream(file);
214
    	this.zipOutputStream = new ZipOutputStream(os);
244
    	this.zipOutputStream = new ZipOutputStream(os);
215
    	Collection c = weave();
245
    	Collection c = weave();
246
    	/* BUG 40943*/
247
    	dumpResources();
216
    	zipOutputStream.close();  //this flushes and closes the acutal file
248
    	zipOutputStream.close();  //this flushes and closes the acutal file
249
		System.out.println("< " + getClass().getName() + ".weave()");
217
    	return c;
250
    	return c;
218
    }
251
    }
219
    
252
    
220
    public Collection weave() throws IOException {
253
    public Collection weave() throws IOException {
254
		System.out.println("> " + getClass().getName() + ".weave()");
221
    	prepareForWeave();
255
    	prepareForWeave();
222
    	Collection filesToWeave;
256
    	Collection filesToWeave;
223
    	
257
    	
Lines 286-291 Link Here
286
        addedClasses = new ArrayList();
320
        addedClasses = new ArrayList();
287
    	deletedTypenames = new ArrayList();
321
    	deletedTypenames = new ArrayList();
288
        
322
        
323
		System.out.println("< " + getClass().getName() + ".weave()");
289
        return wovenClassNames;
324
        return wovenClassNames;
290
    }
325
    }
291
326
Lines 422-427 Link Here
422
	}
457
	}
423
	
458
	
424
	private void writeZipEntry(String name, byte[] bytes) throws IOException {
459
	private void writeZipEntry(String name, byte[] bytes) throws IOException {
460
		System.out.println("? " + getClass().getName() + ".writeZipEntry() name='" + name +"'");
425
		ZipEntry newEntry = new ZipEntry(name);  //??? get compression scheme right
461
		ZipEntry newEntry = new ZipEntry(name);  //??? get compression scheme right
426
		
462
		
427
		zipOutputStream.putNextEntry(newEntry);
463
		zipOutputStream.putNextEntry(newEntry);

Return to bug 40943