xref: /aosp_15_r20/external/javassist/sample/preproc/Assistant.java (revision f1fbf3c2ab775ce834e0af96b7a85bdc7a0eac65)
1*f1fbf3c2SXin Li /*
2*f1fbf3c2SXin Li  * Javassist, a Java-bytecode translator toolkit.
3*f1fbf3c2SXin Li  * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4*f1fbf3c2SXin Li  *
5*f1fbf3c2SXin Li  * The contents of this file are subject to the Mozilla Public License Version
6*f1fbf3c2SXin Li  * 1.1 (the "License"); you may not use this file except in compliance with
7*f1fbf3c2SXin Li  * the License.  Alternatively, the contents of this file may be used under
8*f1fbf3c2SXin Li  * the terms of the GNU Lesser General Public License Version 2.1 or later,
9*f1fbf3c2SXin Li  * or the Apache License Version 2.0.
10*f1fbf3c2SXin Li  *
11*f1fbf3c2SXin Li  * Software distributed under the License is distributed on an "AS IS" basis,
12*f1fbf3c2SXin Li  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13*f1fbf3c2SXin Li  * for the specific language governing rights and limitations under the
14*f1fbf3c2SXin Li  * License.
15*f1fbf3c2SXin Li  */
16*f1fbf3c2SXin Li 
17*f1fbf3c2SXin Li package sample.preproc;
18*f1fbf3c2SXin Li 
19*f1fbf3c2SXin Li import javassist.CtClass;
20*f1fbf3c2SXin Li import javassist.CannotCompileException;
21*f1fbf3c2SXin Li import javassist.ClassPool;
22*f1fbf3c2SXin Li 
23*f1fbf3c2SXin Li /**
24*f1fbf3c2SXin Li  * This is an interface for objects invoked by the
25*f1fbf3c2SXin Li  * Javassist preprocessor when the preprocessor encounters an annotated
26*f1fbf3c2SXin Li  * import declaration.
27*f1fbf3c2SXin Li  *
28*f1fbf3c2SXin Li  * @see sample.preproc.Compiler
29*f1fbf3c2SXin Li  */
30*f1fbf3c2SXin Li public interface Assistant {
31*f1fbf3c2SXin Li     /**
32*f1fbf3c2SXin Li      * Is called when the Javassist preprocessor encounters an
33*f1fbf3c2SXin Li      * import declaration annotated with the "by" keyword.
34*f1fbf3c2SXin Li      *
35*f1fbf3c2SXin Li      * <p>The original import declaration is replaced with new import
36*f1fbf3c2SXin Li      * declarations of classes returned by this method.  For example,
37*f1fbf3c2SXin Li      * the following implementation does not change the original
38*f1fbf3c2SXin Li      * declaration:
39*f1fbf3c2SXin Li      *
40*f1fbf3c2SXin Li      * <ul><pre>
41*f1fbf3c2SXin Li      * public CtClass[] assist(ClassPool cp, String importname, String[] args) {
42*f1fbf3c2SXin Li      *     return new CtClass[] { cp.get(importname) };
43*f1fbf3c2SXin Li      * }
44*f1fbf3c2SXin Li      * </pre></uL>
45*f1fbf3c2SXin Li      *
46*f1fbf3c2SXin Li      * @param cp                class pool
47*f1fbf3c2SXin Li      * @param importname        the class imported by the declaration
48*f1fbf3c2SXin Li      * @param args              the parameters specified by the annotation
49*f1fbf3c2SXin Li      * @return                  the classes imported in the java source
50*f1fbf3c2SXin Li      *                          program produced by the preprocessor.
51*f1fbf3c2SXin Li      */
assist(ClassPool cp, String importname, String[] args)52*f1fbf3c2SXin Li     public CtClass[] assist(ClassPool cp, String importname,
53*f1fbf3c2SXin Li                             String[] args) throws CannotCompileException;
54*f1fbf3c2SXin Li }
55