make/jdk/src/classes/build/tools/depend/Depend.java
author jcbeyler
Thu, 30 Aug 2018 09:47:12 -0700
changeset 51594 dc79850e0254
parent 47398 1fd27535bc57
permissions -rw-r--r--
8203356: VM Object Allocation Collector can infinite recurse Summary: VM Event callback do not provoke a VM alloc event Reviewed-by: sspitsyn, phh, amenkov, cjplummer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47398
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     1
/*
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     4
 *
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    10
 *
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    15
 * accompanied this code).
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    16
 *
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    20
 *
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    23
 * questions.
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    24
 */
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    25
package build.tools.depend;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    26
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    27
import java.io.File;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    28
import java.io.FileInputStream;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    29
import java.io.FileOutputStream;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    30
import java.io.IOException;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    31
import java.io.InputStream;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    32
import java.io.OutputStream;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    33
import java.lang.annotation.Documented;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    34
import java.nio.charset.Charset;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    35
import java.security.MessageDigest;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    36
import java.security.NoSuchAlgorithmException;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    37
import java.util.Arrays;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    38
import java.util.HashMap;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    39
import java.util.HashSet;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    40
import java.util.List;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    41
import java.util.Map;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    42
import java.util.Objects;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    43
import java.util.Set;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    44
import java.util.stream.Collectors;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    45
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    46
import javax.lang.model.element.AnnotationMirror;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    47
import javax.lang.model.element.AnnotationValue;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    48
import javax.lang.model.element.AnnotationValueVisitor;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    49
import javax.lang.model.element.Element;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    50
import javax.lang.model.element.ElementVisitor;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    51
import javax.lang.model.element.ExecutableElement;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    52
import javax.lang.model.element.Modifier;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    53
import javax.lang.model.element.ModuleElement;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    54
import javax.lang.model.element.ModuleElement.DirectiveVisitor;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    55
import javax.lang.model.element.ModuleElement.ExportsDirective;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    56
import javax.lang.model.element.ModuleElement.OpensDirective;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    57
import javax.lang.model.element.ModuleElement.ProvidesDirective;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    58
import javax.lang.model.element.ModuleElement.RequiresDirective;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    59
import javax.lang.model.element.ModuleElement.UsesDirective;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    60
import javax.lang.model.element.PackageElement;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    61
import javax.lang.model.element.QualifiedNameable;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    62
import javax.lang.model.element.TypeElement;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    63
import javax.lang.model.element.TypeParameterElement;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    64
import javax.lang.model.element.VariableElement;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    65
import javax.lang.model.type.ArrayType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    66
import javax.lang.model.type.DeclaredType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    67
import javax.lang.model.type.ErrorType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    68
import javax.lang.model.type.ExecutableType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    69
import javax.lang.model.type.IntersectionType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    70
import javax.lang.model.type.NoType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    71
import javax.lang.model.type.NullType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    72
import javax.lang.model.type.PrimitiveType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    73
import javax.lang.model.type.TypeMirror;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    74
import javax.lang.model.type.TypeVariable;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    75
import javax.lang.model.type.TypeVisitor;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    76
import javax.lang.model.type.UnionType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    77
import javax.lang.model.type.WildcardType;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    78
import javax.lang.model.util.ElementFilter;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    79
import javax.tools.JavaFileObject;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    80
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    81
import com.sun.source.util.JavacTask;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    82
import com.sun.source.util.Plugin;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    83
import com.sun.source.util.TaskEvent;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    84
import com.sun.source.util.TaskEvent.Kind;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    85
import com.sun.source.util.TaskListener;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    86
import com.sun.source.util.TreePath;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    87
import com.sun.source.util.Trees;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    88
import javax.lang.model.element.ElementKind;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    89
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    90
public class Depend implements Plugin {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    91
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    92
    @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    93
    public String getName() {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    94
        return "depend";
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    95
    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    96
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    97
    @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    98
    public void init(JavacTask jt, String... args) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
    99
        jt.addTaskListener(new TaskListener() {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   100
            private final Map<ModuleElement, Set<PackageElement>> apiPackages = new HashMap<>();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   101
            private final MessageDigest apiHash;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   102
            {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   103
                try {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   104
                    apiHash = MessageDigest.getInstance("MD5");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   105
                } catch (NoSuchAlgorithmException ex) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   106
                    throw new IllegalStateException(ex);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   107
                }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   108
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   109
            @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   110
            public void started(TaskEvent te) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   111
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   112
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   113
            @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   114
            public void finished(TaskEvent te) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   115
                if (te.getKind() == Kind.ANALYZE) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   116
                    if (te.getSourceFile().isNameCompatible("module-info", JavaFileObject.Kind.SOURCE)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   117
                        ModuleElement mod = (ModuleElement) Trees.instance(jt).getElement(new TreePath(te.getCompilationUnit()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   118
                        new APIVisitor(apiHash).visit(mod);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   119
                    } else if (te.getSourceFile().isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   120
                        //ignore - cannot contain important changes (?)
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   121
                    } else {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   122
                        TypeElement clazz = te.getTypeElement();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   123
                        ModuleElement mod = jt.getElements().getModuleOf(clazz);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   124
                        Set<PackageElement> thisModulePackages = apiPackages.computeIfAbsent(mod, m -> {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   125
                            return ElementFilter.exportsIn(mod.getDirectives())
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   126
                                                .stream()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   127
                                                .map(ed -> ed.getPackage())
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   128
                                                .collect(Collectors.toSet());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   129
                        });
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   130
                        if (thisModulePackages.contains(jt.getElements().getPackageOf(clazz))) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   131
                            new APIVisitor(apiHash).visit(clazz);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   132
                        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   133
                    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   134
                }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   135
                if (te.getKind() == Kind.COMPILATION) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   136
                    String previousSignature = null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   137
                    File digestFile = new File(args[0]);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   138
                    try (InputStream in = new FileInputStream(digestFile)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   139
                        previousSignature = new String(in.readAllBytes(), "UTF-8");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   140
                    } catch (IOException ex) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   141
                        //ignore
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   142
                    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   143
                    String currentSignature = Depend.this.toString(apiHash.digest());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   144
                    if (!Objects.equals(previousSignature, currentSignature)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   145
                        digestFile.getParentFile().mkdirs();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   146
                        try (OutputStream out = new FileOutputStream(digestFile)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   147
                            out.write(currentSignature.getBytes("UTF-8"));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   148
                        } catch (IOException ex) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   149
                            throw new IllegalStateException(ex);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   150
                        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   151
                    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   152
                }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   153
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   154
        });
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   155
    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   156
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   157
    private String toString(byte[] digest) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   158
        StringBuilder result = new StringBuilder();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   159
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   160
        for (byte b : digest) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   161
            result.append(String.format("%X", b));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   162
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   163
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   164
        return result.toString();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   165
    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   166
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   167
    private static final class APIVisitor implements ElementVisitor<Void, Void>,
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   168
                                                     TypeVisitor<Void, Void>,
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   169
                                                     AnnotationValueVisitor<Void, Void>,
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   170
                                                     DirectiveVisitor<Void, Void> {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   171
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   172
        private final MessageDigest apiHash;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   173
        private final Charset utf8;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   174
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   175
        public APIVisitor(MessageDigest apiHash) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   176
            this.apiHash = apiHash;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   177
            utf8 = Charset.forName("UTF-8");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   178
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   179
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   180
        public Void visit(Iterable<? extends Element> list, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   181
            list.forEach(e -> visit(e, p));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   182
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   183
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   184
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   185
        private void update(CharSequence data) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   186
            apiHash.update(data.toString().getBytes(utf8));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   187
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   188
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   189
        private void visit(Iterable<? extends TypeMirror> types) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   190
            for (TypeMirror type : types) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   191
                visit(type);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   192
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   193
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   194
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   195
        private void updateAnnotation(AnnotationMirror am) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   196
            update("@");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   197
            visit(am.getAnnotationType());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   198
            am.getElementValues()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   199
              .keySet()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   200
              .stream()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   201
              .sorted((ee1, ee2) -> ee1.getSimpleName().toString().compareTo(ee2.getSimpleName().toString()))
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   202
              .forEach(ee -> {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   203
                  visit(ee);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   204
                  visit(am.getElementValues().get(ee));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   205
              });
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   206
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   207
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   208
        private void updateAnnotations(Iterable<? extends AnnotationMirror> annotations) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   209
            for (AnnotationMirror am : annotations) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   210
                if (am.getAnnotationType().asElement().getAnnotation(Documented.class) == null)
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   211
                    continue;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   212
                updateAnnotation(am);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   213
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   214
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   215
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   216
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   217
        public Void visit(Element e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   218
            if (e.getKind() != ElementKind.MODULE &&
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   219
                !e.getModifiers().contains(Modifier.PUBLIC) &&
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   220
                !e.getModifiers().contains(Modifier.PROTECTED)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   221
                return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   222
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   223
            update(e.getKind().name());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   224
            update(e.getModifiers().stream()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   225
                                   .map(mod -> mod.name())
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   226
                                   .collect(Collectors.joining(",", "[", "]")));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   227
            update(e.getSimpleName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   228
            updateAnnotations(e.getAnnotationMirrors());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   229
            return e.accept(this, p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   230
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   231
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   232
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   233
        public Void visit(Element e) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   234
            return visit(e, null);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   235
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   236
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   237
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   238
        public Void visitModule(ModuleElement e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   239
            update(String.valueOf(e.isOpen()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   240
            update(e.getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   241
            e.getDirectives()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   242
             .stream()
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   243
             .forEach(d -> d.accept(this, null));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   244
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   245
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   246
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   247
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   248
        public Void visitPackage(PackageElement e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   249
            throw new UnsupportedOperationException("Should not get here.");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   250
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   251
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   252
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   253
        public Void visitType(TypeElement e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   254
            visit(e.getTypeParameters(), p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   255
            visit(e.getSuperclass());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   256
            visit(e.getInterfaces());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   257
            visit(e.getEnclosedElements(), p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   258
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   259
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   260
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   261
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   262
        public Void visitVariable(VariableElement e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   263
            visit(e.asType());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   264
            update(String.valueOf(e.getConstantValue()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   265
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   266
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   267
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   268
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   269
        public Void visitExecutable(ExecutableElement e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   270
            update("<");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   271
            visit(e.getTypeParameters(), p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   272
            update(">");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   273
            visit(e.getReturnType());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   274
            update("(");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   275
            visit(e.getParameters(), p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   276
            update(")");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   277
            visit(e.getThrownTypes());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   278
            update(String.valueOf(e.getDefaultValue()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   279
            update(String.valueOf(e.isVarArgs()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   280
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   281
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   282
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   283
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   284
        public Void visitTypeParameter(TypeParameterElement e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   285
            visit(e.getBounds());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   286
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   287
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   288
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   289
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   290
        public Void visitUnknown(Element e, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   291
            throw new UnsupportedOperationException("Not supported.");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   292
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   293
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   294
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   295
        public Void visit(TypeMirror t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   296
            if (t == null) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   297
                update("null");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   298
                return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   299
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   300
            update(t.getKind().name());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   301
            updateAnnotations(t.getAnnotationMirrors());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   302
            t.accept(this, p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   303
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   304
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   305
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   306
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   307
        public Void visitPrimitive(PrimitiveType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   308
            return null; //done
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   309
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   310
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   311
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   312
        public Void visitNull(NullType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   313
            return null; //done
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   314
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   315
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   316
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   317
        public Void visitArray(ArrayType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   318
            visit(t.getComponentType());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   319
            update("[]");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   320
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   321
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   322
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   323
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   324
        public Void visitDeclared(DeclaredType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   325
            update(((QualifiedNameable) t.asElement()).getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   326
            update("<");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   327
            visit(t.getTypeArguments());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   328
            update(">");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   329
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   330
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   331
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   332
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   333
        public Void visitError(ErrorType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   334
            return visitDeclared(t, p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   335
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   336
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   337
        private final Set<Element> seenVariables = new HashSet<>();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   338
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   339
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   340
        public Void visitTypeVariable(TypeVariable t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   341
            Element decl = t.asElement();
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   342
            if (!seenVariables.add(decl)) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   343
                return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   344
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   345
            visit(decl, null);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   346
            visit(t.getLowerBound(), null);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   347
            visit(t.getUpperBound(), null);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   348
            seenVariables.remove(decl);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   349
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   350
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   351
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   352
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   353
        public Void visitWildcard(WildcardType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   354
            visit(t.getSuperBound());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   355
            visit(t.getExtendsBound());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   356
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   357
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   358
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   359
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   360
        public Void visitExecutable(ExecutableType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   361
            throw new UnsupportedOperationException("Not supported.");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   362
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   363
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   364
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   365
        public Void visitNoType(NoType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   366
            return null;//done
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   367
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   368
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   369
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   370
        public Void visitUnknown(TypeMirror t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   371
            throw new UnsupportedOperationException("Not supported.");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   372
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   373
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   374
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   375
        public Void visitUnion(UnionType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   376
            update("(");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   377
            visit(t.getAlternatives());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   378
            update(")");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   379
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   380
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   381
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   382
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   383
        public Void visitIntersection(IntersectionType t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   384
            update("(");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   385
            visit(t.getBounds());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   386
            update(")");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   387
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   388
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   389
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   390
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   391
        public Void visit(AnnotationValue av, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   392
            return av.accept(this, p);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   393
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   394
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   395
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   396
        public Void visitBoolean(boolean b, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   397
            update(String.valueOf(b));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   398
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   399
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   400
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   401
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   402
        public Void visitByte(byte b, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   403
            update(String.valueOf(b));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   404
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   405
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   406
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   407
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   408
        public Void visitChar(char c, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   409
            update(String.valueOf(c));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   410
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   411
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   412
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   413
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   414
        public Void visitDouble(double d, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   415
            update(String.valueOf(d));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   416
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   417
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   418
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   419
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   420
        public Void visitFloat(float f, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   421
            update(String.valueOf(f));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   422
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   423
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   424
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   425
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   426
        public Void visitInt(int i, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   427
            update(String.valueOf(i));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   428
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   429
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   430
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   431
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   432
        public Void visitLong(long i, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   433
            update(String.valueOf(i));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   434
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   435
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   436
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   437
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   438
        public Void visitShort(short s, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   439
            update(String.valueOf(s));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   440
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   441
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   442
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   443
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   444
        public Void visitString(String s, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   445
            update(s);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   446
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   447
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   448
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   449
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   450
        public Void visitType(TypeMirror t, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   451
            return visit(t);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   452
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   453
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   454
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   455
        public Void visitEnumConstant(VariableElement c, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   456
            return visit(c);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   457
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   458
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   459
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   460
        public Void visitAnnotation(AnnotationMirror a, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   461
            updateAnnotation(a);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   462
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   463
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   464
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   465
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   466
        public Void visitArray(List<? extends AnnotationValue> vals, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   467
            update("(");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   468
            for (AnnotationValue av : vals) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   469
                visit(av);
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   470
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   471
            update(")");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   472
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   473
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   474
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   475
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   476
        public Void visitUnknown(AnnotationValue av, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   477
            throw new UnsupportedOperationException("Not supported.");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   478
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   479
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   480
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   481
        public Void visitRequires(RequiresDirective d, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   482
            update("RequiresDirective");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   483
            update(String.valueOf(d.isStatic()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   484
            update(String.valueOf(d.isTransitive()));
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   485
            update(d.getDependency().getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   486
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   487
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   488
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   489
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   490
        public Void visitExports(ExportsDirective d, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   491
            update("ExportsDirective");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   492
            update(d.getPackage().getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   493
            if (d.getTargetModules() != null) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   494
                for (ModuleElement me : d.getTargetModules()) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   495
                    update(me.getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   496
                }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   497
            } else {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   498
                update("<none>");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   499
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   500
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   501
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   502
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   503
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   504
        public Void visitOpens(OpensDirective d, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   505
            update("OpensDirective");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   506
            update(d.getPackage().getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   507
            if (d.getTargetModules() != null) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   508
                for (ModuleElement me : d.getTargetModules()) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   509
                    update(me.getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   510
                }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   511
            } else {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   512
                update("<none>");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   513
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   514
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   515
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   516
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   517
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   518
        public Void visitUses(UsesDirective d, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   519
            update("UsesDirective");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   520
            update(d.getService().getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   521
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   522
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   523
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   524
        @Override
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   525
        public Void visitProvides(ProvidesDirective d, Void p) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   526
            update("ProvidesDirective");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   527
            update(d.getService().getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   528
            update("(");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   529
            for (TypeElement impl : d.getImplementations()) {
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   530
                update(impl.getQualifiedName());
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   531
            }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   532
            update(")");
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   533
            return null;
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   534
        }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   535
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   536
    }
1fd27535bc57 8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff changeset
   537
}