Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions make/CompileInterimLangtools.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ define SetupInterimModule
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
$(TOPDIR)/src/$1/share/classes/javax/tools/ToolProvider.java \
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/Main.java \
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/MemoryContext.java \
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/MemoryModuleFinder.java \
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java \
Standard.java, \
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java \
$($1.interim_EXTRA_FILES), \
Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/classes/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
java.instrument,
java.management.rmi,
jdk.jartool,
jdk.compiler,
jdk.jfr,
jdk.jlink,
jdk.jpackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ java.launcher.opt.header = Usage: {0} [options] <mainclass> [args...]\n\
\ {0} [options] --module <module>[/<mainclass>] [args...]\n\
\ (to execute the main class in a module)\n\
\ or {0} [options] <sourcefile> [args]\n\
\ (to execute a single source-file program)\n\n\
\ (to execute a source-file program)\n\n\
\ Arguments following the main class, source file, -jar <jarfile>,\n\
\ -m or --module <module>/<mainclass> are passed as the arguments to\n\
\ main class.\n\n\
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/native/libjli/java.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void FreeKnownVMs();
static jboolean IsWildCardEnabled();


#define SOURCE_LAUNCHER_MAIN_ENTRY "jdk.compiler/com.sun.tools.javac.launcher.Main"
#define SOURCE_LAUNCHER_MAIN_ENTRY "jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher"

/*
* This reports error. VM will not be created and no usage is printed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
import java.util.Map;
import java.util.Set;

import static com.sun.tools.javac.code.Flags.RECORD;
import static com.sun.tools.javac.code.Flags.SEALED;
import static com.sun.tools.javac.code.Flags.NON_SEALED;
import static com.sun.tools.javac.main.Option.PREVIEW;
import com.sun.tools.javac.util.JCDiagnostic;

Expand Down Expand Up @@ -84,7 +81,7 @@ public class Preview {
private final Log log;
private final Source source;

private static final Context.Key<Preview> previewKey = new Context.Key<>();
protected static final Context.Key<Preview> previewKey = new Context.Key<>();

public static Preview instance(Context context) {
Preview instance = context.get(previewKey);
Expand All @@ -94,7 +91,8 @@ public static Preview instance(Context context) {
return instance;
}

Preview(Context context) {
@SuppressWarnings("this-escape")
protected Preview(Context context) {
context.put(previewKey, this);
Options options = Options.instance(context);
names = Names.instance(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.tools.javac.launcher;

import com.sun.tools.javac.util.JCDiagnostic.Error;

import java.io.Serial;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
* A runtime exception used to report errors.
*
* <p><strong>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.</strong></p>
*/
public final class Fault extends RuntimeException {
@Serial
private static final long serialVersionUID = 2L;

private static final String BUNDLE_NAME = "com.sun.tools.javac.resources.launcher";

private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);

private static final String ERROR_PREFIX = RESOURCE_BUNDLE.getString("launcher.error");

/**
* Returns a localized string from a resource bundle.
*
* @param error the error for which to get the localized text
* @return the localized string
*/
private static String getMessage(Error error) {
String key = error.key();
Object[] args = error.getArgs();
try {
String resource = RESOURCE_BUNDLE.getString(key);
String message = MessageFormat.format(resource, args);
return ERROR_PREFIX + message;
} catch (MissingResourceException e) {
return "Cannot access resource; " + key + Arrays.toString(args);
}
}

Fault(Error error) {
super(getMessage(error));
}
}
Loading