# HG changeset patch # User Jaroslav Tulach # Date 1213430062 -7200 # Node ID c27834b52df05569cd7aab61ef5c4bda9345ac36 # Parent 849777d451a5ba1c8191e1d2982e2129e707739f Consistency between type and runtime system diff -r 849777d451a5 -r c27834b52df0 samples/misuse/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/build.xml Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,69 @@ + + + + + + Builds, tests, and runs the project misuse. + + + diff -r 849777d451a5 -r c27834b52df0 samples/misuse/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/nbproject/build-impl.xml Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,627 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + diff -r 849777d451a5 -r c27834b52df0 samples/misuse/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/nbproject/genfiles.properties Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=8bdd6677 +build.xml.script.CRC32=59d6f058 +build.xml.stylesheet.CRC32=be360661 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=8bdd6677 +nbproject/build-impl.xml.script.CRC32=4af44842 +nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08 diff -r 849777d451a5 -r c27834b52df0 samples/misuse/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/nbproject/project.properties Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,59 @@ +application.title=misuse +application.vendor=jarda +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/misuse.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs=-Xlint:unchecked +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff -r 849777d451a5 -r c27834b52df0 samples/misuse/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/nbproject/project.xml Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + misuse + 1.6.5 + + + + + + + + + diff -r 849777d451a5 -r c27834b52df0 samples/misuse/src/org/apidesign/misuse/Connection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/src/org/apidesign/misuse/Connection.java Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,12 @@ +package org.apidesign.misuse; + +// BEGIN: misuse.Connection +public interface Connection { + Savepoint setSavepoint(); + + public interface Savepoint { + void rollback(); + // and other useful operations + } +} +// END: misuse.Connection diff -r 849777d451a5 -r c27834b52df0 samples/misuse/src/org/apidesign/misuse/projectconfig/ProjectConfigurationCorrect.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/src/org/apidesign/misuse/projectconfig/ProjectConfigurationCorrect.java Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,71 @@ +package org.apidesign.misuse.projectconfig; + +public class ProjectConfigurationCorrect { + // BEGIN: misuse.prjconfig.correct + interface ProjectConfigurationProvider { + Configuration[] getConfigurations(); + Configuration getActive(); + void setActive(Configuration c); + } + interface ProjectConfiguration { + public String getDisplayName(); + } + // END: misuse.prjconfig.correct + + + + /* Following does not work: + static { + // BEGIN: misuse.prjconfig.correct.trivial.access + ProjectConfigurationProvider provider = null; // obtain from somewhere; + provider.setActive(provider.getConfigurations()[0]); + // END: misuse.prjconfig.correct.trivial.access + } + */ + + static { + // BEGIN: misuse.prjconfig.correct.access + ProjectConfigurationProvider provider = null; // obtain from somewhere; + resetToZero(provider); + // END: misuse.prjconfig.correct.access + } + + // BEGIN: misuse.prjconfig.correct.openmethod + private static void resetToZero( + ProjectConfigurationProvider provider + ) { + provider.setActive(provider.getConfigurations()[0]); + } + // END: misuse.prjconfig.correct.openmethod + + // BEGIN: misuse.prjconfig.correct.openclass + static void workWithProjectConfigurationProvider(ProjectConfigurationProvider p) { + ResetToZero rtz = ResetToZero.create(p); + rtz.obtainFirst(); + // after a while + rtz.apply(); + } + + static class ResetToZero { + C active; + final ProjectConfigurationProvider provider; + + ResetToZero(ProjectConfigurationProvider provider) { + this.provider = provider; + } + + static ResetToZero create(ProjectConfigurationProvider p) { + return new ResetToZero(p); + } + + public void obtainFirst() { + active = provider.getConfigurations()[0]; + } + + public void apply() { + provider.setActive(active); + } + } + // END: misuse.prjconfig.correct.openclass + +} diff -r 849777d451a5 -r c27834b52df0 samples/misuse/src/org/apidesign/misuse/projectconfig/ProjectConfigurationOriginal.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/misuse/src/org/apidesign/misuse/projectconfig/ProjectConfigurationOriginal.java Sat Jun 14 09:54:22 2008 +0200 @@ -0,0 +1,14 @@ +package org.apidesign.misuse.projectconfig; + +public class ProjectConfigurationOriginal { + // BEGIN: misuse.prjconfig.orig + interface ProjectConfigurationProvider { + ProjectConfiguration[] getConfigurations(); + ProjectConfiguration getActive(); + void setActive(ProjectConfiguration c); + } + interface ProjectConfiguration { + public String getDisplayName(); + } + // END: misuse.prjconfig.orig +}