Java Reference
In-Depth Information
In fact, let's do it now, deliberately—and see how to fix it, using the CowShooter
plugin where you've set up a Git repository.
Bring up CowShooter/src/cowshooter/CowTask.java , and somewhere randomly in the
middle of the file, type some nonsense like “Zombie cows are coming! Run for
your life! Braaaainsss.…” That will do for our example of making a mistake
in a file. Java, of course, is not hip to our warning of the impending zombie-
cow apocalypse, and has no idea what this means. Try to compile with build.sh ,
and you'll see a plethora of angry error messages like this:
src/cowshooter/CowTask.java:20: illegal start of type
Zombie cows are coming! Run for your life! Braaaainsss....
^
src/cowshooter/CowTask.java:20: <identifier> expected
Zombie cows are coming! Run for your life! Braaaainsss....
^
src/cowshooter/CowTask.java:22: ';' expected
public void run() {
^
src/cowshooter/CowTask.java:22: invalid method declaration;
return type required
public void run() {
Argh! Something we typed blew up the compile. Now, if this were a real
emergency you wouldn't know it was the bogus zombie warning text you just
typed in.
So there's an interesting question: what has changed locally in your files that
is different from the last time you did a commit (that is, took a snapshot)?
You can see what's changed by using gitdiff :
$ cd src
$ cd cowshooter
$ git diff CowTask.java
diff --git a/src/cowshooter/CowTask.java b/src/cowshooter/CowTask.java
index 4894201..556d0d3 100644
--- a/src/cowshooter/CowTask.java
+++ b/src/cowshooter/CowTask.java
@@ -16,6 +16,8 @@ public class CowTask extends ServerTask {
cow = myCow;
}
+
+Zombie cows are coming! Run for your life! Braaaainsss....
public void run() {
if (cow.isOnGround()) {
 
 
Search WWH ::




Custom Search