1 /*******************************************************************************
2 * Copyright (c) 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.aspectj.ajdt.internal.compiler;
13 import java.util.Iterator;
15 import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
16 import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
17 import org.aspectj.weaver.bcel.UnwovenClassFile;
18 import org.aspectj.weaver.bcel.UnwovenClassFileWithThirdPartyManagedBytecode;
23 * Adaptor for ClassFiles that lets them act as the bytecode repository
24 * for UnwovenClassFiles (asking a ClassFile for its bytes causes a
27 public class ClassFileBasedByteCodeProvider
28 implements UnwovenClassFileWithThirdPartyManagedBytecode.IByteCodeProvider{
32 public ClassFileBasedByteCodeProvider(ClassFile cf) {
36 public byte[] getBytes() {
40 public static UnwovenClassFile[] unwovenClassFilesFor(CompilationResult result,
41 IOutputClassFileNameProvider nameProvider) {
42 ClassFile[] cfs = result.getClassFiles();
43 UnwovenClassFile[] ret = new UnwovenClassFile[result.compiledTypes.size()];
45 for (Iterator iterator = result.compiledTypes.keySet().iterator(); iterator.hasNext();) {
46 char[] className = (char[])iterator.next();
47 ClassFile cf = (ClassFile)result.compiledTypes.get(className);
48 // OPTIMIZE use char[] for classname
49 ClassFileBasedByteCodeProvider p = new ClassFileBasedByteCodeProvider(cf);
50 String fileName = nameProvider.getOutputClassFileName(cf.fileName(), result);
51 ret[i++] = new UnwovenClassFileWithThirdPartyManagedBytecode(fileName,new String(className).replace('/','.'),p);