From: Chris Koeritz Date: Wed, 27 Feb 2013 21:53:50 +0000 (-0500) Subject: a simple java project for testing some assumptions about the language. X-Git-Tag: 2.140.90~1087 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=a6f0bcc36018952427cbab16387e06ebac58ddb6;p=feisty_meow.git a simple java project for testing some assumptions about the language. --- diff --git a/kona/readme.txt b/kona/readme.txt index f41a4a65..0ecb31e6 100644 --- a/kona/readme.txt +++ b/kona/readme.txt @@ -1,4 +1,8 @@ "kona" is the feisty meow concerns ltd. name for our java components. +other projects may be hidden here also: + + z-testing + this is a test of java semantics and can safely be ignored. diff --git a/kona/z-testing/.classpath b/kona/z-testing/.classpath new file mode 100644 index 00000000..fb565a58 --- /dev/null +++ b/kona/z-testing/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/kona/z-testing/.project b/kona/z-testing/.project new file mode 100644 index 00000000..5f0583eb --- /dev/null +++ b/kona/z-testing/.project @@ -0,0 +1,17 @@ + + + z-testing + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/kona/z-testing/.settings/org.eclipse.jdt.core.prefs b/kona/z-testing/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..e9210e9a --- /dev/null +++ b/kona/z-testing/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Mon Sep 10 12:59:04 EDT 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/kona/z-testing/src/test/java/semantics/behavior_of_finally_when_exception_in_catch.java b/kona/z-testing/src/test/java/semantics/behavior_of_finally_when_exception_in_catch.java new file mode 100644 index 00000000..cbccf0a7 --- /dev/null +++ b/kona/z-testing/src/test/java/semantics/behavior_of_finally_when_exception_in_catch.java @@ -0,0 +1,54 @@ +package test.java.semantics; + +import java.io.FileNotFoundException; + +//import java.util.List; + +class finally_behavior_test +{ + int calibrador = 17; + + public finally_behavior_test() + { + } + + public int funkyTown() throws FileNotFoundException + { + if (calibrador < 3) { + // we should never get here. it should always raise an exception. + System.out.println("where did you put it?"); + } else { + throw new FileNotFoundException("is it larger than a breadbox?"); + } + return 25; + } + + public void runTest() throws Throwable + { + try { + int zooty = funkyTown(); + System.out.println("zooty is " + zooty + " but how did we get here???"); + } catch (Throwable cause) { + System.out.println("caught exception, now will rethrow."); + throw cause; + } finally { + System.out.println("still got to finally, our assumptions are safe."); + } + } + + public static void main(String s[]) throws Exception + { + // we are asserting that the finally clause of an exception handler will still + // fire when an exception is raised in the catch clause. otherwise, all our + // assumptions about being able to use finally properly are thrown out the window. + finally_behavior_test tony = new finally_behavior_test(); + try { + tony.runTest(); + } catch (Throwable cause) { + //yawn. + } + System.out.println("Hey, did the finally clause say it ran above?"); + System.out.println("If so, great. If not, we've got problems."); + } + +} diff --git a/kona/z-testing/src/test/java/semantics/instance_of.java b/kona/z-testing/src/test/java/semantics/instance_of.java new file mode 100644 index 00000000..39008566 --- /dev/null +++ b/kona/z-testing/src/test/java/semantics/instance_of.java @@ -0,0 +1,29 @@ + + +package test.java.semantics; + +import java.util.List; + +class instance_of +{ + public instance_of() {} + + public Object cogitate() { + return null; + } + + public static void main(String s[]) throws Exception + { + // we are just asserting that it is safe to do instanceof on an object that is null. + // let's test that theory. + instance_of tony = new instance_of(); + Object fred = tony.cogitate(); // will produce null. + if (fred instanceof List) { + throw new Exception("that should not have happened!"); + } else { + System.out.println("told us null is not an instance of List, which is correct."); + } + + } + +} \ No newline at end of file