Index: trunk/src/ws/fugue88/jpath/Context.java
===================================================================
--- trunk/src/ws/fugue88/jpath/Context.java	(revision 4)
+++ trunk/src/ws/fugue88/jpath/Context.java	(revision 5)
@@ -3,4 +3,8 @@
  *
  * $Log$
+ * Revision 1.3  2005/08/19 17:51:17  dsowen
+ * Fixed: NPEs when using accessors from paths, &c.  Included tests.
+ * Fixed: parsing exception wasn't very enlightening.
+ *
  * Revision 1.2  2005/08/12 19:01:46  dsowen
  * Feature: can automatically fill missing parts of a graph.
@@ -18,4 +22,5 @@
 package ws.fugue88.jpath;
 
+import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Iterator;
@@ -34,10 +39,9 @@
 	{
 		Context current = this;
-		Accessor accessor = null;
-		for(Iterator i = path.iterator(); i.hasNext();) {
-			accessor = current.getTargetAccessor((PathPart)i.next());
+		for(Iterator i = path.parents().iterator(); i.hasNext();) {
+			Accessor accessor = current.getTargetAccessor((PathPart)i.next());
 			Object obj = accessor.getValue();
 			if(obj == null) {
-				if(_modifying && i.hasNext()) {
+				if(_modifying) {
 					obj = createBlank(accessor.getType());
 					accessor.setValue(obj);
@@ -48,5 +52,5 @@
 			current = new Context(obj, _binder, _modifying);
 		}
-		return accessor;
+		return current.getTargetAccessor(path.terminal());
 	}
 
@@ -109,7 +113,14 @@
 
 	private Object createBlank(final Class type) throws IllegalAccessException,
-			InstantiationException
+			InstantiationException, InvocationTargetException
 	{
-		return type.newInstance();
+		try {
+			final Constructor ctor = type.getDeclaredConstructor(null);
+			ctor.setAccessible(true);
+			return ctor.newInstance(null);
+		} catch(NoSuchMethodException e) {
+			throw new InstantiationException("Class " + type.getName()
+					+ " must have a no-argument constructor.");
+		}
 	}
 
Index: trunk/src/ws/fugue88/jpath/Path.java
===================================================================
--- trunk/src/ws/fugue88/jpath/Path.java	(revision 4)
+++ trunk/src/ws/fugue88/jpath/Path.java	(revision 5)
@@ -3,4 +3,8 @@
  *
  * $Log$
+ * Revision 1.2  2005/08/19 17:51:17  dsowen
+ * Fixed: NPEs when using accessors from paths, &c.  Included tests.
+ * Fixed: parsing exception wasn't very enlightening.
+ *
  * Revision 1.1  2005/08/03 00:35:29  dsowen
  * Initial commit.
@@ -51,5 +55,8 @@
 				pp = new StringSelector(unquote(m.group(1)));
 			} else {
-				throw new ParseException(null, -1);
+				throw new ParseException(
+						"Expected identifier or selector, found '"
+								+ (buff.length() > 40 ? buff.subSequence(0, 37)
+										+ "..." : buff) + "'.", -1);
 			}
 			_parts.add(pp);
@@ -63,7 +70,7 @@
 	}
 
-	public String terminal()
+	public PathPart terminal()
 	{
-		return (String)_parts.get(_parts.size() - 1);
+		return (PathPart)_parts.get(_parts.size() - 1);
 	}
 
