Wed, 09 Jan 2013 20:02:53 -0800
8004730: Add language model support for parameter reflection
Reviewed-by: abuckley
1.1 --- a/src/share/classes/javax/lang/model/element/Element.java Wed Jan 09 10:26:58 2013 -0800 1.2 +++ b/src/share/classes/javax/lang/model/element/Element.java Wed Jan 09 20:02:53 2013 -0800 1.3 @@ -179,6 +179,10 @@ 1.4 * instance initializer}, an empty name is returned. 1.5 * 1.6 * @return the simple name of this element 1.7 + * @see PackageElement#getSimpleName 1.8 + * @see ExecutableElement#getSimpleName 1.9 + * @see TypeElement#getSimpleName 1.10 + * @see VariableElement#getSimpleName 1.11 */ 1.12 Name getSimpleName(); 1.13 1.14 @@ -202,6 +206,11 @@ 1.15 * {@linkplain TypeParameterElement#getGenericElement the 1.16 * generic element} of the type parameter is returned. 1.17 * 1.18 + * <li> If this is a {@linkplain 1.19 + * VariableElement#getEnclosingElement method or constructor 1.20 + * parameter}, {@linkplain ExecutableElement the executable 1.21 + * element} which declares the parameter is returned. 1.22 + * 1.23 * </ul> 1.24 * 1.25 * @return the enclosing element, or {@code null} if there is none
2.1 --- a/src/share/classes/javax/lang/model/element/VariableElement.java Wed Jan 09 10:26:58 2013 -0800 2.2 +++ b/src/share/classes/javax/lang/model/element/VariableElement.java Wed Jan 09 20:02:53 2013 -0800 2.3 @@ -62,4 +62,29 @@ 2.4 * @jls 4.12.4 final Variables 2.5 */ 2.6 Object getConstantValue(); 2.7 + 2.8 + /** 2.9 + * Returns the simple name of this variable element. 2.10 + * 2.11 + * <p>For method and constructor parameters, the name of each 2.12 + * parameter must be distinct from the names of all other 2.13 + * parameters of the same executable. If the original source 2.14 + * names are not available, an implementation may synthesize names 2.15 + * subject to the distinctness requirement above. 2.16 + * 2.17 + * @return the simple name of this variable element 2.18 + */ 2.19 + @Override 2.20 + Name getSimpleName(); 2.21 + 2.22 + /** 2.23 + * Returns the enclosing element of this variable. 2.24 + * 2.25 + * The enclosing element of a method or constructor parameter is 2.26 + * the executable declaring the parameter. 2.27 + * 2.28 + * @return the enclosing element of this variable 2.29 + */ 2.30 + @Override 2.31 + Element getEnclosingElement(); 2.32 }
3.1 --- a/src/share/classes/javax/lang/model/element/package-info.java Wed Jan 09 10:26:58 2013 -0800 3.2 +++ b/src/share/classes/javax/lang/model/element/package-info.java Wed Jan 09 20:02:53 2013 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -48,9 +48,12 @@ 3.11 * {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source} 3.12 * {@linkplain java.lang.annotation.Retention retention} cannot be 3.13 * recovered from class files and class files might not be able to 3.14 - * provide source position information. The {@linkplain 3.15 - * javax.lang.model.element.Modifier modifiers} on an element may 3.16 - * differ in some cases including 3.17 + * provide source position information. 3.18 + * 3.19 + * Names of parameters may not be recoverable from class files. 3.20 + * 3.21 + * The {@linkplain javax.lang.model.element.Modifier modifiers} on an 3.22 + * element may differ in some cases including: 3.23 * 3.24 * <ul> 3.25 * <li> {@code strictfp} on a class or interface