8172810: ModuleElement should declare and provide appropriate modifiers
Reviewed-by: darcy
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java Mon Jan 30 15:08:38 2017 -0800
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java Mon Jan 30 17:43:18 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -63,6 +63,15 @@
List<? extends Element> getEnclosedElements();
/**
+ * Returns {@code true} if this is an open module and {@code
+ * false} otherwise.
+ *
+ * @return {@code true} if this is an open module and {@code
+ * false} otherwise
+ */ // TODO: add @jls to unnamed module section
+ boolean isOpen();
+
+ /**
* Returns {@code true} if this is an unnamed module and {@code
* false} otherwise.
*
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jan 30 15:08:38 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jan 30 17:43:18 2017 -0800
@@ -948,6 +948,11 @@
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public boolean isOpen() {
+ return flags.contains(ModuleFlags.OPEN);
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
public boolean isUnnamed() {
return name.isEmpty() && owner == null;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Mon Jan 30 15:08:38 2017 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Mon Jan 30 17:43:18 2017 -0800
@@ -306,9 +306,9 @@
defaultAction(e, false);
if (!e.isUnnamed()) {
- // TODO: openness of the module not currently exposed
- // by the language model API, but should be printed
- // here once available.
+ if (e.isOpen()) {
+ writer.print("open ");
+ }
writer.println("module " + e.getQualifiedName() + " {");
indentation++;
for (ModuleElement.Directive directive : e.getDirectives()) {