├── .gitignore ├── README.md ├── jars ├── commonslang3.jar └── guava.jar ├── jlink-example1.sh ├── one-module-with-unnamed-illegal-access ├── classpath │ └── de.codecentric.legacy.addresschecker │ │ └── de │ │ └── codecentric │ │ └── legacy │ │ └── addresschecker │ │ ├── api │ │ ├── AddressChecker.java │ │ └── Run.java │ │ └── internal │ │ └── AddressCheckerImpl.java ├── compile-all-modules.sh ├── compile-legacy.sh ├── modulepath │ └── de.codecentric.zipvalidator │ │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ │ └── module-info.java ├── run-from-classpath.sh └── run-from-modulepath.sh ├── one-module-with-unnamed-ok ├── classpath │ └── de.codecentric.legacy.addresschecker │ │ └── de │ │ └── codecentric │ │ └── legacy │ │ └── addresschecker │ │ └── internal │ │ └── AddressCheckerImpl.java ├── compile-all-modules.sh ├── compile-legacy.sh ├── modulepath │ └── de.codecentric.zipvalidator │ │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ └── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ └── module-info.java ├── run-from-classpath.sh └── run-from-modulepath.sh ├── three-modules-exports-to-fail ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.nastymodule │ ├── de │ │ └── codecentric │ │ │ └── nastymodule │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java └── run.sh ├── three-modules-exports-to-ok ├── compile-all.sh ├── de.codecentric.addresschecker │ └── module-info.java ├── de.codecentric.nastymodule │ └── module-info.java ├── de.codecentric.zipvalidator │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java └── run.sh ├── three-modules-no-implied-readability ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator.model │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ └── model │ │ │ └── api │ │ │ └── ZipCodeValidationResult.java │ └── module-info.java └── de.codecentric.zipvalidator │ ├── de │ └── codecentric │ │ └── zipvalidator │ │ ├── api │ │ ├── ZipCodeValidator.java │ │ └── ZipCodeValidatorFactory.java │ │ └── internal │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java ├── three-modules-ok ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator.model │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ └── model │ │ │ └── api │ │ │ └── ZipCodeValidationResult.java │ └── module-info.java ├── de.codecentric.zipvalidator │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java └── run.sh ├── three-modules-with-automatic-module-ok ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator.model │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ └── model │ │ │ └── api │ │ │ └── ZipCodeValidationResult.java │ └── module-info.java ├── de.codecentric.zipvalidator │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java └── run.sh ├── two-modules-compile-time-error ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java └── de.codecentric.zipvalidator │ ├── de │ └── codecentric │ │ └── zipvalidator │ │ ├── api │ │ ├── ZipCodeValidator.java │ │ └── ZipCodeValidatorFactory.java │ │ └── internal │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java ├── two-modules-cyclic ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java └── de.codecentric.zipvalidator │ ├── de │ └── codecentric │ │ └── zipvalidator │ │ ├── api │ │ ├── ZipCodeValidator.java │ │ └── ZipCodeValidatorFactory.java │ │ └── internal │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java ├── two-modules-multiple-versions-different-mod-names ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator.v1 │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator.v2 │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java └── run.sh ├── two-modules-multiple-versions ├── compile-all.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator.v1 │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java └── de.codecentric.zipvalidator.v2 │ ├── de │ └── codecentric │ │ └── zipvalidator │ │ ├── api │ │ ├── ZipCodeValidator.java │ │ └── ZipCodeValidatorFactory.java │ │ └── internal │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java ├── two-modules-ok ├── compile-addresschecker.sh ├── compile-all.sh ├── compile-zipvalidator.sh ├── de.codecentric.addresschecker │ ├── de │ │ └── codecentric │ │ │ └── addresschecker │ │ │ ├── api │ │ │ ├── AddressChecker.java │ │ │ └── Run.java │ │ │ └── internal │ │ │ └── AddressCheckerImpl.java │ └── module-info.java ├── de.codecentric.zipvalidator │ ├── de │ │ └── codecentric │ │ │ └── zipvalidator │ │ │ ├── api │ │ │ ├── ZipCodeValidator.java │ │ │ └── ZipCodeValidatorFactory.java │ │ │ └── internal │ │ │ └── ZipCodeValidatorImpl.java │ └── module-info.java ├── package-addresschecker.sh ├── package-zipvalidator.sh ├── run-from-jar.sh └── run.sh └── two-modules-runtime-error ├── compile-all.sh ├── de.codecentric.addresschecker ├── de │ └── codecentric │ │ └── addresschecker │ │ ├── api │ │ ├── AddressChecker.java │ │ └── Run.java │ │ └── internal │ │ └── AddressCheckerImpl.java └── module-info.java ├── de.codecentric.zipvalidator ├── de │ └── codecentric │ │ └── zipvalidator │ │ ├── api │ │ ├── ZipCodeValidator.java │ │ └── ZipCodeValidatorFactory.java │ │ └── internal │ │ └── ZipCodeValidatorImpl.java └── module-info.java └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/intellij,java 2 | 3 | ### Intellij ### 4 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio 5 | 6 | *.iml 7 | 8 | ## Directory-based project format: 9 | .idea/ 10 | # if you remove the above rule, at least ignore the following: 11 | 12 | # User-specific stuff: 13 | # .idea/workspace.xml 14 | # .idea/tasks.xml 15 | # .idea/dictionaries 16 | 17 | # Sensitive or high-churn files: 18 | # .idea/dataSources.ids 19 | # .idea/dataSources.xml 20 | # .idea/sqlDataSources.xml 21 | # .idea/dynamic.xml 22 | # .idea/uiDesigner.xml 23 | 24 | # Gradle: 25 | # .idea/gradle.xml 26 | # .idea/libraries 27 | 28 | # Mongo Explorer plugin: 29 | # .idea/mongoSettings.xml 30 | 31 | ## File-based project format: 32 | *.ipr 33 | *.iws 34 | 35 | ## Plugin-specific files: 36 | 37 | # IntelliJ 38 | /out/ 39 | 40 | # mpeltonen/sbt-idea plugin 41 | .idea_modules/ 42 | 43 | # JIRA plugin 44 | atlassian-ide-plugin.xml 45 | 46 | # Crashlytics plugin (for Android Studio and IntelliJ) 47 | com_crashlytics_export_strings.xml 48 | crashlytics.properties 49 | crashlytics-build.properties 50 | 51 | 52 | ### Java ### 53 | *.class 54 | 55 | # Mobile Tools for Java (J2ME) 56 | .mtj.tmp/ 57 | 58 | # Package Files # 59 | 60 | *.war 61 | *.ear 62 | 63 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 64 | hs_err_pid* 65 | 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Getting started with Jigsaw 2 | 3 | This repository is a companion to a 2-part Jigsaw blog series on https://blog.codecentric.de 4 | 5 | ###Prerequisites 6 | You need to have Java 9 available on your system. Take care to download the version of JDK 9 that includes Jigsaw from https://jdk9.java.net/jigsaw/. 7 | There is also a version that does not include Jigsaw. 8 | 9 | This project heavily uses shell scripts that expect an environment variable named JAVA9_BIN that leads to the bin folder of the JDK without trailing /, so for example /Applications/jdk1.9.0.jdk/Contents/Home/bin. 10 | 11 | 12 | ##Examples from the first post 13 | 14 | ###Two modules, OK 15 | This example introduces two modules - one module for an address checker with reads (depends on) a zip code validation module. 16 | You can compile the two modules seperately (using the `compile-zipvalidator.sh` and `compile-addresschecker.sh`). Compilation of the addresschecker will fail if you haven't compiled the zipvalidator first. 17 | You can also compile both modules at once by using `compile-all.sh`. 18 | As the modules are well-formed, you can then run the "app" with `run.sh ` where you pass the zip code to check as a param 19 | You can also create modular jars and run the application from those with the provided scripts. 20 | 21 | ###Two modules, compile time error 22 | We try to access a class from a non-exported package of the zip code validator from the address checker. This will result in a compilation error. 23 | 24 | ###Two modules, runtime error 25 | This time we try to access the internal class of the zip code validator by using reflection. This will compile, but execution will fail 26 | 27 | ###Two modules, cyclic 28 | In this example, we introduce cyclic dependencies. This will fail to compile 29 | 30 | ###Three modules, no implied readability 31 | This example introduces a new module that the zip code validator depends on. Compilation will fail because the public api of the zip code validator uses a class from this new module, but does not export it transitively 32 | 33 | ###Three modules, ok 34 | This fixes the problems from "three modules, no implied readability" by transitively exporting the new module 35 | 36 | ##Examples from the second post 37 | 38 | ###Three modules, exports-to ok 39 | This demonstrates how to restrict exports to certain modules 40 | 41 | ###Three modules, exports-to fails 42 | This shows what happens when you try to access a type that was not exported to you 43 | 44 | ###Two modules, multiple versions 45 | In this example, we create a new version of the zipvalidator, but keep the name and put both on the module path 46 | 47 | ###Two modules, multiple versions, different module names 48 | In this example, we create a new version of the zipvalidator, change the module name and put both on the module path 49 | 50 | ###Three modules with automatic module ok 51 | This example includes the usage of automatic module guava 52 | 53 | ###One module with unnamed, illegal access 54 | Here we use a module from a non-modular class, but do not stick to module rules 55 | 56 | ###One module with unnamed, ok 57 | Here we use a module from a non-modular class and stick to module rules 58 | -------------------------------------------------------------------------------- /jars/commonslang3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftrossbach/IntroToJigsaw/06982af79dc8cc2e91450d678fc6c7c448648180/jars/commonslang3.jar -------------------------------------------------------------------------------- /jars/guava.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ftrossbach/IntroToJigsaw/06982af79dc8cc2e91450d678fc6c7c448648180/jars/guava.jar -------------------------------------------------------------------------------- /jlink-example1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | cd two-modules-ok 4 | ./package-zipvalidator.sh 5 | ./package-addresschecker.sh 6 | cd .. 7 | $JAVA9_BIN/jlink ---module-path $JAVA9_BIN/../../images/jmods/:two-modules-ok/bin --addmods de.codecentric.addresschecker --output linkedjdk --exclude-files *.diz --compress-resources on --strip-java-debug on --compress-resources-level 2 -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/classpath/de.codecentric.legacy.addresschecker/de/codecentric/legacy/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.legacy.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/classpath/de.codecentric.legacy.addresschecker/de/codecentric/legacy/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.legacy.addresschecker.api; 2 | 3 | import de.codecentric.legacy.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/classpath/de.codecentric.legacy.addresschecker/de/codecentric/legacy/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.legacy.addresschecker.internal; 2 | 3 | import de.codecentric.legacy.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 5 | 6 | 7 | 8 | /** 9 | * Created by ftr on 06/11/15. 10 | */ 11 | public class AddressCheckerImpl implements AddressChecker { 12 | @Override 13 | public boolean checkZipCode(String zipCode) { 14 | return new ZipCodeValidatorImpl().zipCodeIsValid(zipCode); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/compile-all-modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d modulepath --module-source-path modulepath $(find modulepath -name "*.java") 4 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/compile-legacy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -g -d classpath/de.codecentric.legacy.addresschecker/ -classpath modulepath/de.codecentric.zipvalidator/ $(find classpath -name "*.java") -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/modulepath/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | 4 | /** 5 | * Created by ftr on 06/11/15. 6 | */ 7 | public interface ZipCodeValidator { 8 | 9 | boolean zipCodeIsValid(String zipCode); 10 | } 11 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/modulepath/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/modulepath/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | 6 | 7 | 8 | /** 9 | * Created by ftr on 06/11/15. 10 | */ 11 | public class ZipCodeValidatorImpl implements ZipCodeValidator { 12 | 13 | @Override 14 | public boolean zipCodeIsValid(String zipCode) { 15 | 16 | if (zipCode == null || "".equals(zipCode)) { 17 | return false; 18 | } else if (zipCode.length() < 5) { 19 | return false; 20 | } else if (zipCode.length() > 5) { 21 | return false; 22 | } else { 23 | return true; 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/modulepath/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | 4 | 5 | } -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/run-from-classpath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java -cp modulepath/de.codecentric.zipvalidator/:classpath/de.codecentric.legacy.addresschecker/ de.codecentric.legacy.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /one-module-with-unnamed-illegal-access/run-from-modulepath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path modulepath -addmods de.codecentric.zipvalidator -cp classpath/de.codecentric.legacy.addresschecker/ de.codecentric.legacy.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/classpath/de.codecentric.legacy.addresschecker/de/codecentric/legacy/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.legacy.addresschecker.internal; 2 | 3 | import de.codecentric.legacy.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | 7 | 8 | /** 9 | * Created by ftr on 06/11/15. 10 | */ 11 | public class AddressCheckerImpl implements AddressChecker { 12 | @Override 13 | public boolean checkZipCode(String zipCode) { 14 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/compile-all-modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d modulepath --module-source-path modulepath $(find modulepath -name "*.java") 4 | -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/compile-legacy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d classpath/de.codecentric.legacy.addresschecker/ -classpath modulepath/de.codecentric.zipvalidator/ $(find classpath -name "*.java") -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/modulepath/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | 4 | /** 5 | * Created by ftr on 06/11/15. 6 | */ 7 | public interface ZipCodeValidator { 8 | 9 | boolean zipCodeIsValid(String zipCode); 10 | } 11 | -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/modulepath/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/modulepath/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | 4 | 5 | } -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/run-from-classpath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java -cp modulepath/de.codecentric.zipvalidator/:classpath/de.codecentric.legacy.addresschecker/ de.codecentric.legacy.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /one-module-with-unnamed-ok/run-from-modulepath.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path modulepath -addmods de.codecentric.zipvalidator -classpath classpath/de.codecentric.legacy.addresschecker/ de.codecentric.legacy.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | public class AddressCheckerImpl implements AddressChecker { 7 | @Override 8 | public boolean checkZipCode(String zipCode) { 9 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.nastymodule/de/codecentric/nastymodule/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.nastymodule.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.nastymodule/de/codecentric/nastymodule/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.nastymodule.api; 2 | 3 | import de.codecentric.nastymodule.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.nastymodule/de/codecentric/nastymodule/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.nastymodule.internal; 2 | 3 | import de.codecentric.nastymodule.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | public class AddressCheckerImpl implements AddressChecker { 7 | @Override 8 | public boolean checkZipCode(String zipCode) { 9 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.nastymodule/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.nastymodule{ 2 | exports de.codecentric.nastymodule.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-exports-to-fail/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | 3 | exports de.codecentric.zipvalidator.api to de.codecentric.addresschecker; 4 | 5 | } -------------------------------------------------------------------------------- /three-modules-exports-to-fail/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path . -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /three-modules-exports-to-ok/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /three-modules-exports-to-ok/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /three-modules-exports-to-ok/de.codecentric.nastymodule/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.nastymodule{ 2 | exports de.codecentric.nastymodule.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /three-modules-exports-to-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /three-modules-exports-to-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /three-modules-exports-to-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-exports-to-ok/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | 3 | exports de.codecentric.zipvalidator.api to de.codecentric.addresschecker, de.codecentric.nastymodule; 4 | 5 | } -------------------------------------------------------------------------------- /three-modules-exports-to-ok/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path . -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 6 | 7 | 8 | 9 | /** 10 | * Created by ftr on 06/11/15. 11 | */ 12 | public class AddressCheckerImpl implements AddressChecker { 13 | @Override 14 | public boolean checkZipCode(String zipCode) { 15 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode) == ZipCodeValidationResult.OK; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | } -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.zipvalidator.model/de/codecentric/zipvalidator/model/api/ZipCodeValidationResult.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.model.api; 2 | 3 | 4 | /** 5 | * Created by ftr on 06/11/15. 6 | */ 7 | public enum ZipCodeValidationResult { 8 | 9 | OK, ZIP_CODE_NULL, ZIP_CODE_TOO_SHORT, ZIP_CODE_TOO_LONG 10 | } 11 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.zipvalidator.model/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator.model{ 2 | exports de.codecentric.zipvalidator.model.api; 3 | 4 | 5 | 6 | } -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public interface ZipCodeValidator { 9 | 10 | ZipCodeValidationResult zipCodeIsValid(String zipCode); 11 | } 12 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 5 | 6 | /** 7 | * Created by ftr on 06/11/15. 8 | */ 9 | public class ZipCodeValidatorImpl implements ZipCodeValidator { 10 | 11 | @Override 12 | public ZipCodeValidationResult zipCodeIsValid(String zipCode) { 13 | 14 | if (zipCode == null) { 15 | return ZipCodeValidationResult.ZIP_CODE_NULL; 16 | } else if (zipCode.length() < 5) { 17 | return ZipCodeValidationResult.ZIP_CODE_TOO_SHORT; 18 | } else if (zipCode.length() > 5) { 19 | return ZipCodeValidationResult.ZIP_CODE_TOO_LONG; 20 | } else { 21 | return ZipCodeValidationResult.OK; 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /three-modules-no-implied-readability/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | requires de.codecentric.zipvalidator.model; 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /three-modules-ok/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 6 | 7 | 8 | /** 9 | * Created by ftr on 06/11/15. 10 | */ 11 | public class AddressCheckerImpl implements AddressChecker { 12 | @Override 13 | public boolean checkZipCode(String zipCode) { 14 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode) == ZipCodeValidationResult.OK; 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.zipvalidator.model/de/codecentric/zipvalidator/model/api/ZipCodeValidationResult.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.model.api; 2 | 3 | 4 | /** 5 | * Created by ftr on 06/11/15. 6 | */ 7 | public enum ZipCodeValidationResult { 8 | 9 | OK, ZIP_CODE_NULL, ZIP_CODE_TOO_SHORT, ZIP_CODE_TOO_LONG 10 | } 11 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.zipvalidator.model/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator.model{ 2 | exports de.codecentric.zipvalidator.model.api; 3 | 4 | 5 | 6 | } -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public interface ZipCodeValidator { 9 | 10 | ZipCodeValidationResult zipCodeIsValid(String zipCode); 11 | } 12 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 5 | 6 | /** 7 | * Created by ftr on 06/11/15. 8 | */ 9 | public class ZipCodeValidatorImpl implements ZipCodeValidator { 10 | 11 | @Override 12 | public ZipCodeValidationResult zipCodeIsValid(String zipCode) { 13 | 14 | if (zipCode == null) { 15 | return ZipCodeValidationResult.ZIP_CODE_NULL; 16 | } else if (zipCode.length() < 5) { 17 | return ZipCodeValidationResult.ZIP_CODE_TOO_SHORT; 18 | } else if (zipCode.length() > 5) { 19 | return ZipCodeValidationResult.ZIP_CODE_TOO_LONG; 20 | } else { 21 | return ZipCodeValidationResult.OK; 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /three-modules-ok/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | requires public de.codecentric.zipvalidator.model; 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /three-modules-ok/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path . -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-path ../jars --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 6 | 7 | 8 | /** 9 | * Created by ftr on 06/11/15. 10 | */ 11 | public class AddressCheckerImpl implements AddressChecker { 12 | @Override 13 | public boolean checkZipCode(String zipCode) { 14 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode) == ZipCodeValidationResult.OK; 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.zipvalidator.model/de/codecentric/zipvalidator/model/api/ZipCodeValidationResult.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.model.api; 2 | 3 | 4 | /** 5 | * Created by ftr on 06/11/15. 6 | */ 7 | public enum ZipCodeValidationResult { 8 | 9 | OK, ZIP_CODE_NULL_OR_EMPTY, ZIP_CODE_TOO_SHORT, ZIP_CODE_TOO_LONG 10 | } 11 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.zipvalidator.model/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator.model{ 2 | exports de.codecentric.zipvalidator.model.api; 3 | 4 | 5 | 6 | } -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public interface ZipCodeValidator { 9 | 10 | ZipCodeValidationResult zipCodeIsValid(String zipCode); 11 | } 12 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | import de.codecentric.zipvalidator.model.api.ZipCodeValidationResult; 5 | import com.google.common.base.Strings; 6 | 7 | 8 | /** 9 | * Created by ftr on 06/11/15. 10 | */ 11 | public class ZipCodeValidatorImpl implements ZipCodeValidator { 12 | 13 | @Override 14 | public ZipCodeValidationResult zipCodeIsValid(String zipCode) { 15 | 16 | if (Strings.isNullOrEmpty(zipCode)) { 17 | return ZipCodeValidationResult.ZIP_CODE_NULL_OR_EMPTY; 18 | } else if (zipCode.length() < 5) { 19 | return ZipCodeValidationResult.ZIP_CODE_TOO_SHORT; 20 | } else if (zipCode.length() > 5) { 21 | return ZipCodeValidationResult.ZIP_CODE_TOO_LONG; 22 | } else { 23 | return ZipCodeValidationResult.OK; 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | requires public de.codecentric.zipvalidator.model; 4 | 5 | 6 | requires guava; 7 | 8 | } -------------------------------------------------------------------------------- /three-modules-with-automatic-module-ok/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path .:../jars -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 5 | 6 | /** 7 | * Created by ftr on 06/11/15. 8 | */ 9 | public class AddressCheckerImpl implements AddressChecker { 10 | @Override 11 | public boolean checkZipCode(String zipCode) { 12 | 13 | 14 | return new ZipCodeValidatorImpl().zipCodeIsValid(zipCode); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator { 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-compile-time-error/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | 4 | 5 | 6 | } -------------------------------------------------------------------------------- /two-modules-cyclic/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | /** 7 | * Created by ftr on 06/11/15. 8 | */ 9 | public class AddressCheckerImpl implements AddressChecker { 10 | @Override 11 | public boolean checkZipCode(String zipCode) { 12 | 13 | 14 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-cyclic/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | requires de.codecentric.addresschecker; 3 | exports de.codecentric.zipvalidator.api; 4 | 5 | } -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | /** 7 | * Created by ftr on 06/11/15. 8 | */ 9 | public class AddressCheckerImpl implements AddressChecker { 10 | @Override 11 | public boolean checkZipCode(String zipCode) { 12 | 13 | 14 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator.v1; 4 | requires de.codecentric.zipvalidator.v2; 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v1/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v1/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v1/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | System.out.println("v1"); 12 | return zipCode != null && zipCode.length() == 5; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v1/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator.v1{ 2 | 3 | exports de.codecentric.zipvalidator.api; 4 | 5 | } -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v2/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v2/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v2/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | System.out.println("v1"); 12 | 13 | return zipCode != null && zipCode.length() == 5; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/de.codecentric.zipvalidator.v2/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator.v2{ 2 | 3 | exports de.codecentric.zipvalidator.api; 4 | 5 | } -------------------------------------------------------------------------------- /two-modules-multiple-versions-different-mod-names/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path . -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | /** 7 | * Created by ftr on 06/11/15. 8 | */ 9 | public class AddressCheckerImpl implements AddressChecker { 10 | @Override 11 | public boolean checkZipCode(String zipCode) { 12 | 13 | 14 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v1/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v1/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v1/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v1/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | 3 | exports de.codecentric.zipvalidator.api; 4 | 5 | } -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v2/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v2/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v2/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-multiple-versions/de.codecentric.zipvalidator.v2/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | 3 | exports de.codecentric.zipvalidator.api; 4 | 5 | } -------------------------------------------------------------------------------- /two-modules-ok/compile-addresschecker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac --module-path . -d de.codecentric.addresschecker $(find de.codecentric.addresschecker -name "*.java") -------------------------------------------------------------------------------- /two-modules-ok/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /two-modules-ok/compile-zipvalidator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d de.codecentric.zipvalidator $(find de.codecentric.zipvalidator -name "*.java") -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidatorFactory; 5 | 6 | public class AddressCheckerImpl implements AddressChecker { 7 | @Override 8 | public boolean checkZipCode(String zipCode) { 9 | return ZipCodeValidatorFactory.getInstance().zipCodeIsValid(zipCode); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-ok/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | 3 | exports de.codecentric.zipvalidator.api; 4 | 5 | } -------------------------------------------------------------------------------- /two-modules-ok/package-addresschecker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | mkdir bin 4 | $JAVA9_BIN/jar --create --file=bin/addresschecker.jar --module-version=1.0 --main-class=de.codecentric.addresschecker.api.Run -C de.codecentric.addresschecker . -------------------------------------------------------------------------------- /two-modules-ok/package-zipvalidator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | mkdir bin 4 | $JAVA9_BIN/jar --create --file=bin/zipvalidator.jar --module-version=1.0 -C de.codecentric.zipvalidator . -------------------------------------------------------------------------------- /two-modules-ok/run-from-jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java -p bin -m de.codecentric.addresschecker $1 4 | -------------------------------------------------------------------------------- /two-modules-ok/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path . -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | -------------------------------------------------------------------------------- /two-modules-runtime-error/compile-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/javac -d . --module-source-path . $(find . -name "*.java") 4 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.addresschecker/de/codecentric/addresschecker/api/AddressChecker.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface AddressChecker { 7 | 8 | public boolean checkZipCode(String zipCode); 9 | 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.addresschecker/de/codecentric/addresschecker/api/Run.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.api; 2 | 3 | import de.codecentric.addresschecker.internal.AddressCheckerImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class Run { 9 | 10 | public static void main(String[] args) { 11 | 12 | String value = args.length > 0 ? args[0] : ""; 13 | boolean isZipCode = new AddressCheckerImpl().checkZipCode(value); 14 | if(isZipCode){ 15 | System.out.println(value + " is a valid zip code"); 16 | } else { 17 | System.out.println(value + " is not a valid zip code"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.addresschecker/de/codecentric/addresschecker/internal/AddressCheckerImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.addresschecker.internal; 2 | 3 | import de.codecentric.addresschecker.api.AddressChecker; 4 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 5 | 6 | 7 | /** 8 | * Created by ftr on 06/11/15. 9 | */ 10 | public class AddressCheckerImpl implements AddressChecker { 11 | @Override 12 | public boolean checkZipCode(String zipCode) { 13 | ClassLoader classLoader = AddressCheckerImpl.class.getClassLoader(); 14 | try { 15 | Class aClass = classLoader.loadClass("de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl"); 16 | return ((ZipCodeValidator)aClass.newInstance()).zipCodeIsValid(zipCode); 17 | } catch (Exception e) { 18 | throw new RuntimeException(e); 19 | } 20 | 21 | 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.addresschecker/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.addresschecker{ 2 | exports de.codecentric.addresschecker.api; 3 | requires de.codecentric.zipvalidator; 4 | 5 | 6 | 7 | } -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidator.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | /** 4 | * Created by ftr on 06/11/15. 5 | */ 6 | public interface ZipCodeValidator { 7 | 8 | boolean zipCodeIsValid(String zipCode); 9 | } 10 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.zipvalidator/de/codecentric/zipvalidator/api/ZipCodeValidatorFactory.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.api; 2 | 3 | import de.codecentric.zipvalidator.internal.ZipCodeValidatorImpl; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorFactory { 9 | 10 | public static ZipCodeValidator getInstance(){ 11 | 12 | return new ZipCodeValidatorImpl(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.zipvalidator/de/codecentric/zipvalidator/internal/ZipCodeValidatorImpl.java: -------------------------------------------------------------------------------- 1 | package de.codecentric.zipvalidator.internal; 2 | 3 | import de.codecentric.zipvalidator.api.ZipCodeValidator; 4 | 5 | /** 6 | * Created by ftr on 06/11/15. 7 | */ 8 | public class ZipCodeValidatorImpl implements ZipCodeValidator{ 9 | @Override 10 | public boolean zipCodeIsValid(String zipCode) { 11 | return zipCode != null && zipCode.length() == 5; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /two-modules-runtime-error/de.codecentric.zipvalidator/module-info.java: -------------------------------------------------------------------------------- 1 | module de.codecentric.zipvalidator{ 2 | exports de.codecentric.zipvalidator.api; 3 | 4 | 5 | 6 | } -------------------------------------------------------------------------------- /two-modules-runtime-error/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x #echo on 3 | $JAVA9_BIN/java --module-path . -m de.codecentric.addresschecker/de.codecentric.addresschecker.api.Run $1 4 | --------------------------------------------------------------------------------