head 1.5; access; symbols bg2_23:1.4 bg2_22:1.4 bg2_21:1.4 bg2_20:1.4 bg2_16:1.4 bg2_15:1.4 bg2_12:1.4 bg2_07:1.4 isorc2008_submission:1.3 handbook_alpha_edition:1.3 jtres2007_submission:1.3 bg1_07:1.3 bg1_06:1.3 bg1_05:1.3 TAL_101:1.2 TAL_100:1.2 jtres_submission:1.2 wises06_submission:1.2 lctes2006_submission:1.2 rtgc_isorc2006:1.2.0.4 isorc2006:1.2.0.2 rtgc_paper:1.2 bg1_00:1.2 nohandle:1.1; locks; strict; comment @# @; 1.5 date 2008.09.20.22.19.59; author martin; state Exp; branches; next 1.4; commitid 34be48d5770d4567; 1.4 date 2008.02.24.23.03.38; author martin; state Exp; branches; next 1.3; commitid 215347c1f7c74567; 1.3 date 2006.11.14.12.21.07; author martin; state Exp; branches; next 1.2; commitid 578e4559b4ac4567; 1.2 date 2005.06.14.13.58.28; author martin; state Exp; branches; next 1.1; commitid 447c42aee27d4567; 1.1 date 2005.06.08.21.16.36; author martin; state Exp; branches; next ; commitid 772542a760304567; desc @@ 1.5 log @Provide a common base for JOPizer and other tools @ text @/* This file is part of JOP, the Java Optimized Processor see Copyright (C) Markus Dahm Copyright (C) 2005,2006, Martin Schoeberl (martin@@jopdesign.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* * Created on 04.06.2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com.jopdesign.build; import org.apache.bcel.classfile.*; import org.apache.bcel.generic.*; import org.apache.bcel.util.*; import java.io.*; import java.util.*; import org.apache.bcel.Constants; import org.apache.bcel.Repository; /** * Find all classes referenced by given start class and all classes * referenced by tjose and so on. In other words: Compute the tranitive * hull of classes used by a given class. This is done by checking all * ConstantClass entries and all method and field signatures.
This * may be useful in order to put all class files of an application * into a single JAR file. *

* It fails however in the presence of reflection code. * * @@author M. Dahm */ public class TransitiveHull extends org.apache.bcel.classfile.EmptyVisitor { private ClassPath classpath; private JavaClass _class; private ClassQueue _queue; private ClassSet _set; private ConstantPool _cp; private String[] _ignored = { /* "java[.].*", "javax[.].*", "com[.]sun[.].*" */ }; private String[] excluded = {}; public TransitiveHull(JavaClass clazz) { _queue = new ClassQueue(); _queue.enqueue(clazz); _set = new ClassSet(); _set.add(clazz); } public TransitiveHull(JavaClass[] clazz) { _queue = new ClassQueue(); _set = new ClassSet(); for (int i=0; i