langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java
author jjg
Wed, 05 Nov 2014 19:12:45 -0800
changeset 27388 d694da45bd7a
parent 26992 92e69fa21956
child 31115 8d8e98052d5d
permissions -rw-r--r--
8062676: Tests which leak lots of file managers should be fixed (group 2) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25605
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     1
/*
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     4
 *
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    10
 *
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    15
 * accompanied this code).
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    16
 *
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    20
 *
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    23
 * questions.
c2d72342fe19 8050408: A few new Java src files for sjavac are missing copyright notices
jjg
parents: 25299
diff changeset
    24
 */
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    25
package com.sun.tools.sjavac.comp;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    26
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    27
import java.io.File;
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    28
import java.io.IOException;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    29
import java.io.PrintWriter;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    30
import java.io.StringWriter;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    31
import java.net.URI;
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
    32
import java.nio.file.Paths;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    33
import java.util.Arrays;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    34
import java.util.List;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    35
import java.util.Set;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    36
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    37
import javax.tools.JavaFileObject;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    38
import javax.tools.StandardJavaFileManager;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    39
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
    40
import com.sun.source.tree.CompilationUnitTree;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    41
import com.sun.tools.javac.api.JavacTaskImpl;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    42
import com.sun.tools.javac.api.JavacTool;
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
    43
import com.sun.tools.javac.code.Symbol.ClassSymbol;
26991
88d998b3bb4b 8056258: Analysis of public API does not take super classes into account
alundblad
parents: 26107
diff changeset
    44
import com.sun.tools.javac.code.Symbol.PackageSymbol;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    45
import com.sun.tools.javac.util.Context;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    46
import com.sun.tools.javac.util.ListBuffer;
26098
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    47
import com.sun.tools.javac.util.Options;
26991
88d998b3bb4b 8056258: Analysis of public API does not take super classes into account
alundblad
parents: 26107
diff changeset
    48
import com.sun.tools.sjavac.Util;
88d998b3bb4b 8056258: Analysis of public API does not take super classes into account
alundblad
parents: 26107
diff changeset
    49
import com.sun.tools.sjavac.comp.dependencies.DependencyCollector;
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
    50
import com.sun.tools.sjavac.comp.dependencies.PublicApiCollector;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    51
import com.sun.tools.sjavac.server.CompilationResult;
26098
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    52
import com.sun.tools.sjavac.server.Sjavac;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    53
import com.sun.tools.sjavac.server.SysInfo;
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    54
26098
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    55
/**
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    56
 * The sjavac implementation that interacts with javac and performs the actual
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    57
 * compilation.
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    58
 *
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    59
 *  <p><b>This is NOT part of any supported API.
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    60
 *  If you write code that depends on this, you do so at your own risk.
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    61
 *  This code and its internal interfaces are subject to change or
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    62
 *  deletion without notice.</b>
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    63
 */
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
    64
public class SjavacImpl implements Sjavac {
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    65
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    66
    @Override
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    67
    public SysInfo getSysInfo() {
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    68
        return new SysInfo(Runtime.getRuntime().availableProcessors(),
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    69
                           Runtime.getRuntime().maxMemory());
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    70
    }
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    71
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    72
    @Override
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    73
    public CompilationResult compile(String protocolId,
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    74
                                     String invocationId,
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    75
                                     String[] args,
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    76
                                     List<File> explicitSources,
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    77
                                     Set<URI> sourcesToCompile,
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    78
                                     Set<URI> visibleSources) {
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    79
        JavacTool compiler = JavacTool.create();
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    80
        try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    81
            SmartFileManager smartFileManager = new SmartFileManager(fileManager);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    82
            Context context = new Context();
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    83
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    84
            // Now setup the actual compilation....
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    85
            CompilationResult compilationResult = new CompilationResult(0);
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
    86
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    87
            // First deal with explicit source files on cmdline and in at file.
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    88
            ListBuffer<JavaFileObject> compilationUnits = new ListBuffer<>();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    89
            for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(explicitSources)) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    90
                compilationUnits.append(i);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    91
            }
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    92
            // Now deal with sources supplied as source_to_compile.
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    93
            ListBuffer<File> sourcesToCompileFiles = new ListBuffer<>();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    94
            for (URI u : sourcesToCompile) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    95
                sourcesToCompileFiles.append(new File(u));
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    96
            }
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    97
            for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    98
                compilationUnits.append(i);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
    99
            }
26991
88d998b3bb4b 8056258: Analysis of public API does not take super classes into account
alundblad
parents: 26107
diff changeset
   100
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   101
            // Create a new logger.
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   102
            StringWriter stdoutLog = new StringWriter();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   103
            StringWriter stderrLog = new StringWriter();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   104
            PrintWriter stdout = new PrintWriter(stdoutLog);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   105
            PrintWriter stderr = new PrintWriter(stderrLog);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   106
            com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK;
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   107
            DependencyCollector depsCollector = new DependencyCollector();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   108
            PublicApiCollector pubApiCollector = new PublicApiCollector();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   109
            PathAndPackageVerifier papVerifier = new PathAndPackageVerifier();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   110
            try {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   111
                if (compilationUnits.size() > 0) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   112
                    smartFileManager.setVisibleSources(visibleSources);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   113
                    smartFileManager.cleanArtifacts();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   114
                    smartFileManager.setLog(stdout);
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
   115
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   116
                    // Do the compilation!
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   117
                    JavacTaskImpl task =
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   118
                            (JavacTaskImpl) compiler.getTask(stderr,
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   119
                                                             smartFileManager,
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   120
                                                             null,
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   121
                                                             Arrays.asList(args),
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   122
                                                             null,
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   123
                                                             compilationUnits,
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   124
                                                             context);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   125
                    smartFileManager.setSymbolFileEnabled(!Options.instance(context).isSet("ignore.symbol.file"));
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   126
                    task.addTaskListener(depsCollector);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   127
                    task.addTaskListener(pubApiCollector);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   128
                    task.addTaskListener(papVerifier);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   129
                    rc = task.doCall();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   130
                    smartFileManager.flush();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   131
                }
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   132
            } catch (Exception e) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   133
                stderrLog.append(Util.getStackTrace(e));
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   134
                rc = com.sun.tools.javac.main.Main.Result.ERROR;
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
   135
            }
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
   136
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   137
            compilationResult.packageArtifacts = smartFileManager.getPackageArtifacts();
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
   138
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   139
            Dependencies deps = Dependencies.instance(context);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   140
            for (PackageSymbol from : depsCollector.getSourcePackages()) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   141
                for (PackageSymbol to : depsCollector.getDependenciesForPkg(from))
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   142
                    deps.collect(from.fullname, to.fullname);
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   143
            }
26991
88d998b3bb4b 8056258: Analysis of public API does not take super classes into account
alundblad
parents: 26107
diff changeset
   144
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   145
            for (ClassSymbol cs : pubApiCollector.getClassSymbols())
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   146
                deps.visitPubapi(cs);
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
   147
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   148
            if (papVerifier.getMisplacedCompilationUnits().size() > 0) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   149
                for (CompilationUnitTree cu : papVerifier.getMisplacedCompilationUnits()) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   150
                    System.err.println("Misplaced compilation unit.");
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   151
                    System.err.println("    Directory: " + Paths.get(cu.getSourceFile().toUri()).getParent());
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   152
                    System.err.println("    Package:   " + cu.getPackageName());
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   153
                }
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   154
                rc = com.sun.tools.javac.main.Main.Result.ERROR;
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
   155
            }
27388
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   156
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   157
            compilationResult.packageDependencies = deps.getDependencies();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   158
            compilationResult.packagePubapis = deps.getPubapis();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   159
            compilationResult.stdout = stdoutLog.toString();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   160
            compilationResult.stderr = stderrLog.toString();
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   161
            compilationResult.returnCode = rc.exitCode;
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   162
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   163
            return compilationResult;
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   164
        } catch (IOException e) {
d694da45bd7a 8062676: Tests which leak lots of file managers should be fixed (group 2)
jjg
parents: 26992
diff changeset
   165
            throw new Error(e);
26992
92e69fa21956 8059349: Public API scanning should be implemented in the form of a TaskListener
alundblad
parents: 26991
diff changeset
   166
        }
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
   167
    }
26088
f479ca655ba1 8054474: Add --state-dir=bar to sjavac
ohrstrom
parents: 25605
diff changeset
   168
f479ca655ba1 8054474: Add --state-dir=bar to sjavac
ohrstrom
parents: 25605
diff changeset
   169
    @Override
26098
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   170
    public void shutdown() {
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   171
        // Nothing to clean up
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   172
        // ... maybe we should wait for any current request to finish?
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   173
    }
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   174
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   175
32588700060b 8048457: Sjavac should not use portfiles, sockets, etc if background=false
alundblad
parents: 26088
diff changeset
   176
    @Override
26088
f479ca655ba1 8054474: Add --state-dir=bar to sjavac
ohrstrom
parents: 25605
diff changeset
   177
    public String serverSettings() {
f479ca655ba1 8054474: Add --state-dir=bar to sjavac
ohrstrom
parents: 25605
diff changeset
   178
        return "";
f479ca655ba1 8054474: Add --state-dir=bar to sjavac
ohrstrom
parents: 25605
diff changeset
   179
    }
f479ca655ba1 8054474: Add --state-dir=bar to sjavac
ohrstrom
parents: 25605
diff changeset
   180
25299
b4a7dcd657f5 8048594: The sjavac client/server protocol should be hidden behind an interface
alundblad
parents:
diff changeset
   181
}