HEAD - Fixed bug 341394: Remove 'Unavailable' JMX attributes of WebAppContext MBean
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
index d263d4b..7d186a9 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java
index 4942f51..be01c68 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2009 BEA Systems, Inc.
+ * Copyright (c) 2007, 2011 BEA Systems, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *    wharley@bea.com - initial API and implementation
+ *    IBM Corporation - Fix for bug 341494
  *******************************************************************************/
 
 package org.eclipse.jdt.compiler.apt.tests.processors.elementutils;
@@ -28,6 +29,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.Elements;
 
 import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
 
@@ -42,6 +44,7 @@
 {
 	// Initialized in collectElements()
 	private TypeElement _elementF;
+	private TypeElement _elementConstants;
 	private TypeElement _elementFChild;
 	private TypeElement _elementFEnum;
 	private TypeElement _elementG;
@@ -106,7 +109,9 @@
 		if (!examineOverrides()) {
 			return false;
 		}
-		
+		if (!examineGetConstantExpression()) {
+			return false;
+		}
 		reportSuccess();
 		return false;
 	}
@@ -177,7 +182,11 @@
 			reportError("Could not find value() method in annotation type AnnoY");
 			return false;
 		}
-		
+		_elementConstants = _elementUtils.getTypeElement("targets.model.pc.Constants");
+		if (_elementConstants == null || _elementConstants.getKind() != ElementKind.CLASS) {
+			reportError("_elementConstants was not found or was not a class");
+			return false;
+		}
 		return true;
 	}
 	
@@ -591,6 +600,37 @@
 	}
 	
 	/**
+	 * Test the {@link Elements#getConstantExpression(Object)} method for fields
+	 * @return true if all tests passed
+	 */
+	private boolean examineGetConstantExpression() {
+		for (VariableElement field : ElementFilter.fieldsIn(_elementConstants.getEnclosedElements())) {
+			Object constantValue = field.getConstantValue();
+			if (constantValue instanceof String) {
+				String constantExpression = _elementUtils.getConstantExpression(constantValue);
+				if (constantExpression == null
+						|| constantExpression.charAt(0) != '\"'
+						|| constantExpression.charAt(constantExpression.length() - 1) != '\"') {
+					return false;
+				}
+			} else if (constantValue instanceof Character) {
+				String constantExpression = _elementUtils.getConstantExpression(constantValue);
+				if (constantExpression == null
+						|| constantExpression.charAt(0) != '\''
+						|| constantExpression.charAt(constantExpression.length() - 1) != '\'') {
+					return false;
+				}
+			} else {
+				String constantExpression = _elementUtils.getConstantExpression(constantValue);
+				if (constantExpression == null) {
+					return false;
+				}
+			}
+		}
+		return true;
+	}
+
+	/**
 	 * Test the {@link Elements#hides(Element, Element)} method for nested classes
 	 * @return true if all tests passed
 	 */
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Constants.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Constants.java
new file mode 100644
index 0000000..64805b4
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Constants.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package targets.model.pc;
+
+public class Constants {
+	public static final double C1 = 0.125;
+	public static final int C2 = 2;
+	public static final long C3 = 10;
+	public static final float C4 = 0.2f;
+	public static final boolean C5 = true;
+	public static final char C6 = ' ';
+	public static final short C7 = (short) 256;
+	public static final byte C8 = 1;
+	public static final String C9 = "Hello World";
+}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
index 67baade..fa650cc 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2008 BEA Systems, Inc.
+ * Copyright (c) 2006, 2011 BEA Systems, Inc.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
  *
  * Contributors:
  *    wharley@bea.com - initial API and implementation
- *
+ *    IBM Corporation - Fix for bug 341494
  *******************************************************************************/
 
 package org.eclipse.jdt.internal.compiler.apt.model;
@@ -274,6 +274,14 @@
 			StringBuilder builder = new StringBuilder();
 			builder.append('\'').append(value).append('\'');
 			return String.valueOf(builder);
+		} else if (value instanceof String) {
+			StringBuilder builder = new StringBuilder();
+			builder.append('\"').append(value).append('\"');
+			return String.valueOf(builder);
+		} else if (value instanceof Float) {
+			return String.valueOf(value)+'f';
+		} else if (value instanceof Long) {
+			return String.valueOf(value)+'L';
 		}
 		return String.valueOf(value);
 	}