Skip to content

Commit

Permalink
Don't supply --release 8 and --add-opens together
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored May 8, 2021
1 parent c0043b0 commit 4517075
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions do_like_javac/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def main():
sys.exit(1)

javac_commands, jars, stats = result
if len(javac_commands) == 0:
raise Exception("command.main: no javac commands found by capturer:\n cmd = {}\n args = {}".format(cmd, args))

log.info('Results: %s', pprint.pformat(javac_commands))
output_json(os.path.join(args.output_directory, 'javac.json'), javac_commands)
Expand Down
12 changes: 10 additions & 2 deletions do_like_javac/tools/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def run(args, javac_commands, jars):
checker_command += getArgumentsByVersion(args.jdkVersion)

for jc in javac_commands:
## What is the point of this pprint command, whose result is not used?
pprint.pformat(jc)
javac_switches = jc['javac_switches']
cp = javac_switches['classpath']
Expand All @@ -31,7 +32,8 @@ def run(args, javac_commands, jars):
cmd = checker_command + ["-classpath", cp] + java_files
common.run_cmd(cmd, args, 'check')

def getArgumentsByVersion(jdkVersion):
## other_args is other command-line arguments to javac
def getArgumentsByVersion(jdkVersion, other_args=[]):
if jdkVersion is not None:
version = int(jdkVersion)
else:
Expand All @@ -41,7 +43,13 @@ def getArgumentsByVersion(jdkVersion):
if version == 8:
result += ['-J-Xbootclasspath/p:' + os.environ['CHECKERFRAMEWORK'] + '/checker/dist/javac.jar']
elif version == 11:
result += ['-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED']
release_8 = False
for i, str in enumerate(other_args):
if str == '--release' and other_args[i+1] == "8":
release_8 = True
if not release_8:
# Avoid javac "error: option --add-opens not allowed with target 1.8"
result += ['-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED']
else:
raise ValueError("the Checker Framework only supports Java versions 8 and 11")

Expand Down
3 changes: 2 additions & 1 deletion do_like_javac/tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def run_cmd(cmd, args=None, tool=None):
timer = None
out = None
out_file = None
friendly_cmd = ' '.join(cmd)
# Without quoting, empty arguments don't appear in friendly_cmd
friendly_cmd = ' '.join("'" + elt + "'" for elt in cmd)

if args and args.verbose and args.log_to_stderr:
out = sys.stderr
Expand Down
12 changes: 10 additions & 2 deletions do_like_javac/tools/wpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def run(args, javac_commands, jars):
else:
jdkVersion = 8

checker_command += check.getArgumentsByVersion(jdkVersion)

if args.extraJavacArgs is not None:
checker_command += args.extraJavacArgs.split()

Expand Down Expand Up @@ -114,6 +112,7 @@ def run(args, javac_commands, jars):
if args.lib_dir:
cp += pp + args.lib_dir + ':'

release8 = False
other_args = []
for k, v in javac_switches.items():
if k not in ignored_options and not k.startswith(ignored_options_prefixes):
Expand All @@ -125,6 +124,8 @@ def run(args, javac_commands, jars):
# the build, and this is the best that DLJC can do in this situation.
if v in ["1.5", "5", "1.6", "6", "1.7", "7", "1.8"]:
v = "8"
if v == "8":
release8 = True
# Do not use source/target, because Java 11 JVMs will
# crash on some classes, e.g.
# https://bugs.openjdk.java.net/browse/JDK-8212636.
Expand All @@ -139,6 +140,13 @@ def run(args, javac_commands, jars):
if v is not None and v is not True:
other_args.append(str(v))

checker_command += check.getArgumentsByVersion(jdkVersion, other_args)

if release8:
# Avoid javac "error: option --add-opens not allowed with target 1.8"
checker_command = [arg for arg in checker_command if not arg.startswith("--add-opens")]
other_args = [arg for arg in other_args if not arg.startswith("--add-opens")]

while diffResult != 0:

iterationStubs = ':'.join(stubDirs)
Expand Down

0 comments on commit 4517075

Please sign in to comment.