Author: tchemit Date: 2009-11-27 02:43:31 +0100 (Fri, 27 Nov 2009) New Revision: 1660 Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java Log: add log and do not break build when a binding is bad (since it can not be for the moment...) Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-11-27 01:29:37 UTC (rev 1659) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-11-27 01:43:31 UTC (rev 1660) @@ -37,6 +37,8 @@ import jaxx.compiler.tags.DefaultObjectHandler; import jaxx.compiler.tags.TagManager; import jaxx.compiler.types.TypeManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.beans.Introspector; import java.beans.PropertyChangeListener; @@ -45,9 +47,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * Represents a Java expression which fires a <code>PropertyChangeEvent</code> when it can be * determined that its value may have changed. Events are fired on a "best effort" basis, and events @@ -388,6 +387,9 @@ * @return the type of the symbol (or null if it could not be determined). */ private ClassDescriptor scanCompoundSymbol(String symbol, ClassDescriptor contextClass, boolean isMethod) { + if (log.isDebugEnabled()) { + log.debug("for symbol " + symbol + " and contextClass " + contextClass + ", isMethod " + isMethod); + } String[] tokens = symbol.split("\\s*\\.\\s*"); StringBuffer currentSymbol = new StringBuffer(); StringBuffer tokensSeenSoFar = new StringBuffer(); @@ -418,7 +420,13 @@ try { FieldDescriptor field = contextClass.getFieldDescriptor(memberName); trackMemberIfPossible(tokensSeenSoFar.toString(), contextClass, field.getName(), false); - contextClass = field.getType(); + try { + contextClass = field.getType(); + } catch (Exception e) { + log.warn("could not find type for field " + field); + throw new NoSuchFieldException(e.getMessage()); + } + currentSymbol.setLength(0); accepted = true; recognizeClassNames = false; @@ -427,16 +435,26 @@ FieldDescriptor[] newFields = compiler.getScriptFields(); for (FieldDescriptor newField : newFields) { if (newField.getName().equals(memberName)) { + try { + contextClass = newField.getType(); + } catch (Exception e2) { + // try to get a generic type + CompiledObject compiledObject = compiler.getCompiledObject(newField.getName()); + log.warn("could not find type for field " + newField + " membername " + memberName + ", compiledObject : " + compiledObject); + contextClass = null; + continue; + } addListener(tokensSeenSoFar.toString(), null, "addPropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator(), "removePropertyChangeListener(\"" + memberName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator()); - contextClass = newField.getType(); + assert contextClass != null : "script field '" + memberName + "' is defined, but has type null"; currentSymbol.setLength(0); accepted = true; recognizeClassNames = false; break; + } } }