Skip to content


8297444: Refactor the javacserver build tool
Browse files Browse the repository at this point in the history
Reviewed-by: erikj, cstein
  • Loading branch information
magicus committed Dec 1, 2022
1 parent e846b04 commit 257aa15
Show file tree
Hide file tree
Showing 29 changed files with 905 additions and 1,918 deletions.
24 changes: 14 additions & 10 deletions make/common/JavaCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -219,31 +219,35 @@ define SetupJavaCompilationBody
# Use java server if it is enabled, and the user does not want a specialized
# class path.
ifeq ($$(ENABLE_JAVAC_SERVER)+$$($1_CLASSPATH), true+)
$1_JAVAC := $$(INTERIM_LANGTOOLS_ARGS) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_javacserver_classes javacserver.Main

# Create a configuration file with the needed information for the javac
# server to function properly.
$1_JAVAC_SERVER_CONFIG := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)-server.conf
$1_JAVAC_SERVER_CONFIG := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)-javacserver.conf

# Arguments needed to launch the javacserver client, as well as for the
# client to launch the server.
-cp $(BUILDTOOLS_OUTPUTDIR)/langtools_javacserver_classes

# The portfile contains the tcp/ip on which the server listens
# and the cookie necessary to talk to the server.
$1_JAVAC_PORT_FILE := $$(call FixPath, $$(JAVAC_SERVER_DIR)/server.port)

# The servercmd specifies how to launch the server. This will be executed
# by the client, if needed.
$1_JAVAC_SERVER_CMD := $$(call FixPath, $$(JAVA) $$($1_JAVA_FLAGS) $$($1_JAVAC))
# The javacmd tells the client how to run java to launch the server.
$1_JAVAC_SERVER_JAVA_CMD := $$(call FixPath, $$(JAVA) $$($1_JAVA_FLAGS) \

$1_CONFIG_VARDEPS_FILE := $$(call DependOnVariable, $1_CONFIG_VARDEPS, \

# Write these values to a config file
$(ECHO) portfile=$$($1_JAVAC_PORT_FILE) > $$@
$(ECHO) servercmd=$$($1_JAVAC_SERVER_CMD) >> $$@
$(ECHO) javacmd=$$($1_JAVAC_SERVER_JAVA_CMD) >> $$@

# Always use small java to launch client
$1_JAVAC_CMD := $$(JAVA_SMALL) $$($1_JAVA_FLAGS) $$($1_JAVAC) \
javacserver.Main --conf=$$($1_JAVAC_SERVER_CONFIG)
# No javac server
$1_JAVAC := $$(INTERIM_LANGTOOLS_ARGS) -m jdk.compiler.interim/
Expand Down
29 changes: 4 additions & 25 deletions make/langtools/tools/javacserver/
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,13 @@

package javacserver;

import java.util.Arrays;

import javacserver.client.ClientMain;
import javacserver.server.ServerMain;

import static javacserver.options.Option.STARTSERVER;
import javacserver.client.Client;

* The application entry point of the smart javac wrapper tool.
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
* The application entry point of the javacserver build tool.
public class Main {

public static void main(String... args) {

public static int go(String[] args) {

// Server or client mode?
boolean serverMode = Arrays.asList(args)
.anyMatch(arg -> arg.startsWith(STARTSERVER.arg));

return serverMode ? :;
public static void main(String... args) {
148 changes: 0 additions & 148 deletions make/langtools/tools/javacserver/

This file was deleted.

1 comment on commit 257aa15

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.