From 9659aa6adfc781fd0b0c489de33bf477f855dcb8 Mon Sep 17 00:00:00 2001 From: Bruce Eckel Date: Thu, 7 Jul 2016 16:23:19 -0600 Subject: [PATCH] latest {main: fixes --- serialization/xfiles/ThawAlien.java | 4 +++- staticchecking/dr/DogsAndRobots.java | 1 + staticchecking/drc/DogAndRobotCollections.java | 1 + staticchecking/latent/Latent.java | 1 + staticchecking/petspeak/PetSpeak.java | 1 + typeinfo/FamilyVsExactType.java | 1 + typeinfo/pets/LiteralPetCreator.java | 1 + typeinfo/toys/GenericToyTest.java | 1 + typeinfo/toys/ToyTest.java | 1 + 9 files changed, 11 insertions(+), 1 deletion(-) diff --git a/serialization/xfiles/ThawAlien.java b/serialization/xfiles/ThawAlien.java index 0032abde..75baba0b 100644 --- a/serialization/xfiles/ThawAlien.java +++ b/serialization/xfiles/ThawAlien.java @@ -3,6 +3,8 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Recover a serialized file +// {main: serialization.xfiles.ThawAlien} +// {RunFirst: FreezeAlien} package serialization.xfiles; import java.io.*; @@ -10,7 +12,7 @@ public class ThawAlien { public static void main(String[] args) throws Exception { ObjectInputStream in = new ObjectInputStream( - new FileInputStream(new File("..", "X.file"))); + new FileInputStream(new File("X.file"))); Object mystery = in.readObject(); System.out.println(mystery.getClass()); } diff --git a/staticchecking/dr/DogsAndRobots.java b/staticchecking/dr/DogsAndRobots.java index d44f74b9..67f68e82 100644 --- a/staticchecking/dr/DogsAndRobots.java +++ b/staticchecking/dr/DogsAndRobots.java @@ -2,6 +2,7 @@ // (c)2016 MindView LLC: see Copyright.txt // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. +// {main: staticchecking.dr.DogsAndRobots} package staticchecking.dr; interface Speaks { void talk(); } diff --git a/staticchecking/drc/DogAndRobotCollections.java b/staticchecking/drc/DogAndRobotCollections.java index 382a74ad..06c62a78 100644 --- a/staticchecking/drc/DogAndRobotCollections.java +++ b/staticchecking/drc/DogAndRobotCollections.java @@ -2,6 +2,7 @@ // (c)2016 MindView LLC: see Copyright.txt // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. +// {main: staticchecking.drc.DogAndRobotCollections} package staticchecking.drc; import java.util.*; diff --git a/staticchecking/latent/Latent.java b/staticchecking/latent/Latent.java index e49f5af7..bd9e8606 100644 --- a/staticchecking/latent/Latent.java +++ b/staticchecking/latent/Latent.java @@ -2,6 +2,7 @@ // (c)2016 MindView LLC: see Copyright.txt // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. +// {main: staticchecking.latent.Latent} package staticchecking.latent; import java.lang.reflect.*; diff --git a/staticchecking/petspeak/PetSpeak.java b/staticchecking/petspeak/PetSpeak.java index 3a3d79c6..b2847bb4 100644 --- a/staticchecking/petspeak/PetSpeak.java +++ b/staticchecking/petspeak/PetSpeak.java @@ -3,6 +3,7 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Speaking pets in Java +// {main: staticchecking.petspeak.PetSpeak} package staticchecking.petspeak; interface Pet { diff --git a/typeinfo/FamilyVsExactType.java b/typeinfo/FamilyVsExactType.java index b73b6253..33f3a862 100644 --- a/typeinfo/FamilyVsExactType.java +++ b/typeinfo/FamilyVsExactType.java @@ -3,6 +3,7 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // The difference between instanceof and class +// {main: typeinfo.FamilyVsExactType} package typeinfo; class Base {} diff --git a/typeinfo/pets/LiteralPetCreator.java b/typeinfo/pets/LiteralPetCreator.java index ffdafe74..7c75e49e 100644 --- a/typeinfo/pets/LiteralPetCreator.java +++ b/typeinfo/pets/LiteralPetCreator.java @@ -3,6 +3,7 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Using class literals +// {main: typeinfo.pets.LiteralPetCreator} package typeinfo.pets; import java.util.*; diff --git a/typeinfo/toys/GenericToyTest.java b/typeinfo/toys/GenericToyTest.java index 73492fa5..009bf7ce 100644 --- a/typeinfo/toys/GenericToyTest.java +++ b/typeinfo/toys/GenericToyTest.java @@ -3,6 +3,7 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Testing class Class +// {main: typeinfo.toys.GenericToyTest} package typeinfo.toys; public class GenericToyTest { diff --git a/typeinfo/toys/ToyTest.java b/typeinfo/toys/ToyTest.java index 247577ea..b3e3f0e3 100644 --- a/typeinfo/toys/ToyTest.java +++ b/typeinfo/toys/ToyTest.java @@ -3,6 +3,7 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Testing class Class +// {main: typeinfo.toys.ToyTest} package typeinfo.toys; interface HasBatteries {}