changeset 3927:a21e5b9dc5c3

8172810: ModuleElement should declare and provide appropriate modifiers Reviewed-by: darcy
author jjg
date Mon, 30 Jan 2017 17:43:18 -0800
parents b7bb3f51028a
children dfcfdb2db85f
files src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Mon Jan 30 15:08:38 2017 -0800
+++ b/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/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Jan 30 15:08:38 2017 -0800
+++ b/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/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Mon Jan 30 15:08:38 2017 -0800
+++ b/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()) {