summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt/server
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2011-08-31 14:03:28 +0000
committerHenri Sara <henri.sara@itmill.com>2011-08-31 14:03:28 +0000
commit5ffa4eb1f2827c70db5078c39efb3f652b59a259 (patch)
tree0882ed8f76cf22d0e86cfa08487d581f88197458 /src/com/vaadin/terminal/gwt/server
parent75e550ae5c057c67dac3ba7dc8fc5d5d72b8b623 (diff)
downloadvaadin-framework-5ffa4eb1f2827c70db5078c39efb3f652b59a259.tar.gz
vaadin-framework-5ffa4eb1f2827c70db5078c39efb3f652b59a259.zip
#7479 WebSphere 8 class loading problem workaround (similar to old GlassFish 3.0.0 workaround)
svn changeset:20778/svn branch:6.7
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server')
-rw-r--r--src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java110
1 files changed, 67 insertions, 43 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
index 2f9a614b5f..28789b0ebc 100644
--- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
+++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
@@ -11,6 +11,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Serializable;
+import java.io.StringWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -1040,65 +1041,88 @@ public class JsonPaintTarget implements PaintTarget {
private boolean hasClientWidgetMapping(Class<? extends Paintable> class1) {
try {
return class1.isAnnotationPresent(ClientWidget.class);
+ } catch (NoClassDefFoundError e) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ String stacktrace = writer.toString();
+ if (stacktrace
+ .contains("com.ibm.oti.reflect.AnnotationParser.parseClass")) {
+ // #7479 IBM JVM apparently tries to eagerly load the classes
+ // referred to by annotations. Checking the annotation from byte
+ // code to be sure that we are dealing the this case and not
+ // some other class loading issue.
+ if (bytecodeContainsClientWidgetAnnotation(class1)) {
+ return true;
+ }
+ } else {
+ // throw exception forward
+ throw e;
+ }
} catch (RuntimeException e) {
if (e.getStackTrace()[0].getClassName().equals(
"org.glassfish.web.loader.WebappClassLoader")) {
+ // See #3920
// Glassfish 3 is darn eager to load the value class, even
// though we just want to check if the annotation exists.
- // See #3920, remove this hack when fixed in glassfish
+
// In some situations (depending on class loading order) it
// would be enough to return true here, but it is safer to check
- // the annotation from bytecode
+ // the annotation from byte code
- String name = class1.getName().replace('.', File.separatorChar)
- + ".class";
+ if (bytecodeContainsClientWidgetAnnotation(class1)) {
+ return true;
+ }
+ } else {
+ // throw exception forward
+ throw e;
+ }
+ }
+ return false;
+ }
- try {
- InputStream stream = class1.getClassLoader()
- .getResourceAsStream(name);
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(stream));
- try {
- String line;
- boolean atSourcefile = false;
- while ((line = bufferedReader.readLine()) != null) {
- if (line.startsWith("SourceFile")) {
- atSourcefile = true;
- }
- if (atSourcefile) {
- if (line.contains("ClientWidget")) {
- return true;
- }
- }
- // TODO could optize to quit at the end attribute
- }
- } catch (IOException e1) {
- logger.log(
- Level.SEVERE,
- "An error occurred while finding widget mapping.",
- e1);
- } finally {
- try {
- bufferedReader.close();
- } catch (IOException e1) {
- logger.log(Level.SEVERE, "Could not close reader.",
- e1);
+ private boolean bytecodeContainsClientWidgetAnnotation(
+ Class<? extends Paintable> class1) {
+
+ try {
+ String name = class1.getName().replace('.', File.separatorChar)
+ + ".class";
+
+ InputStream stream = class1.getClassLoader().getResourceAsStream(
+ name);
+ BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(stream));
+ try {
+ String line;
+ boolean atSourcefile = false;
+ while ((line = bufferedReader.readLine()) != null) {
+ if (line.startsWith("SourceFile")) {
+ atSourcefile = true;
+ }
+ if (atSourcefile) {
+ if (line.contains("ClientWidget")) {
+ return true;
}
}
-
- } catch (Throwable e2) {
- logger.log(Level.SEVERE,
- "An error occurred while finding widget mapping.",
- e2);
+ // TODO could optimize to quit at the end attribute
}
+ } catch (IOException e1) {
+ logger.log(Level.SEVERE,
+ "An error occurred while finding widget mapping.", e1);
+ } finally {
+ try {
+ bufferedReader.close();
+ } catch (IOException e1) {
+ logger.log(Level.SEVERE, "Could not close reader.", e1);
- return false;
- } else {
- // throw exception forward
- throw e;
+ }
}
+ } catch (Throwable t) {
+ logger.log(Level.SEVERE,
+ "An error occurred while finding widget mapping.", t);
}
+
+ return false;
}
Collection<Class<? extends Paintable>> getUsedPaintableTypes() {