1 /* 2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in 5 * compliance with the License. 6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or 9 * glassfish/bootstrap/legal/CDDLv1.0.txt. 10 * See the License for the specific language governing 11 * permissions and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by 18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]" 20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 22 */ 23 24 /* 25 * ClosureCompiler.java 26 * 27 * Created on September 7, 2004, 5:02 PM 28 */ 29 30 package com.sun.enterprise.tools.verifier.apiscan.classfile; 31 32 import java.util.Collection; 33 import java.util.Map; 34 35 /** 36 * This is single most important interface of the apiscan package. This class is 37 * used to compute the complete closure of a set of classes. 38 * 39 * @author Sanjeeb.Sahoo@Sun.COM 40 * @see ClosureCompilerImpl 41 */ 42 public interface ClosureCompiler { 43 /** 44 * @param externalClsName class name (in external format) whose closure will 45 * be computed. 46 * @return true if it can compute the closure for all the classes that are 47 * new to it, else false. In other words, this operation is not 48 * idempotent. e.g. ClosureCompiler cc; cc.reset(); boolean 49 * first=cc.buildClosure("a.B"); boolean second=cc.buildClosure("a.B"); 50 * second will always be true irrespective of value of first. This 51 * is because it uses list of classes that it has already visited. 52 * That list gets cleared when {@link #reset()} is called). 53 */ 54 boolean buildClosure(String externalClsName); 55 56 /** 57 * @return unmodifiable collection of class names which it visited during 58 * closure computation. e.g. Let's say a.class references b1.class 59 * and b2.class. b1.class references c1.class, c2.class and c3.class 60 * b2.class references d1.class, d2.class and d3.class. 61 * c1/c2/d1/d2.class are all not loadable where as c3 and d3.class 62 * are loadable. When we build the closure of a.class, closure will 63 * contain the following... {"a", "b1", "b2", "c3", "d3"} 64 */ 65 Collection getClosure(); 66 67 /** 68 * @return unmodifiable collection of class names whose closure could not be 69 * computed. The typical reason for not able to build closure for a 70 * class is that class not being found in loader's search path. See 71 * it returns a map which is keyed by the access path and the value 72 * is a list of class names which could not be loaded. e.g. Let's 73 * say a.class references b1.class and b2.class. b1.class references 74 * c1.class, c2.class and c3.class b2.class references d1.class, 75 * d2.class and d3.class. c1/c2/d1/d2.class are all not loadable 76 * where as c3 and d3.class are loadable. When we build the closure 77 * of a.class, failed map will contain the following... {("a:b1", 78 * {"c1","c2"}), ("a.b2", {"d1","d2"})} 79 */ 80 Map getFailed(); 81 82 /** 83 * Clear the internal cache. It includes the result it has collected since 84 * last reset(). But it does not clear the excludedd list. If you want to 85 * reset the excluded list, create a new ClosureCompiler. 86 */ 87 void reset(); 88 89 } 90