Repository: immutables/immutables
Issue: Why declared immuables library style in package-info.java doesn't apply for subpackages in java 9 project?

Please see https://github.com/originalrusyn/java9_immutables for more details

So, the following config works correctly with sourceCompatibility = 1.8

```
p.package-info.java

@Value.Style(
    defaults = @Value.Immutable(copy = false),
    strictBuilder = true,
    overshadowImplementation = true,
    implementationNestedInBuilder = true
)
package p;

import org.immutables.value.Value;
```

build.gradle

```
buildscript {
    ext {
        immutablesVersion = '2.5.6'
    }
    repositories {
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath "net.ltgt.gradle:gradle-apt-plugin:0.13"
    }
}

group 'java9'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'net.ltgt.apt'

sourceCompatibility = 1.9

repositories {
    mavenCentral()
}

sourceSets {
    main
    generated
    test
}

compileJava {
    generatedSourcesDestinationDir = "$projectDir/src/generated/java"
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
}

dependencies {
    apt "org.immutables:value:${immutablesVersion}"

    compileOnly "org.immutables:value:${immutablesVersion}:annotations"

    testCompile group: 'junit', name: 'junit', version: '4.12'
}
```

p.b.B.java

```
package p.b;

import org.immutables.value.Value;

@Value.Immutable
public interface B {

    String getText();
}
```

Why does it produce p.b.ImmutableB.java rather than p.b.BBuilder.java for sourceCompatibility=1.9?

Changed files:
value-processor/src/org/immutables/value/processor/meta/SourceNames.java, value-processor/src/org/immutables/value/processor/meta/Proto.java

diff --git a/value-processor/src/org/immutables/value/processor/meta/Proto.java b/value-processor/src/org/immutables/value/processor/meta/Proto.java
index 3b07678b..7c55ab44 100644
--- a/value-processor/src/org/immutables/value/processor/meta/Proto.java
+++ b/value-processor/src/org/immutables/value/processor/meta/Proto.java
@@ -723,7 +723,7 @@ public class Proto {
     @Value.Lazy
     Optional<DeclaringPackage> namedParentPackage() {
       String parentPackageName = SourceNames.parentPackageName(element());
-      if (!parentPackageName.isEmpty()) {
+      while (!parentPackageName.isEmpty()) {
         @Nullable PackageElement parentPackage =
             environment().processing()
                 .getElementUtils()
@@ -737,6 +737,11 @@ public class Proto {
                   .element(parentPackage)
                   .build()));
         }
+
+        // With JDK 9+ package elements are only returned for packages with a
+        // `package-info.class` file. So although the parent may not be found,
+        // there may be "ancestor packages" further up the hierarchy.
+        parentPackageName = SourceNames.parentPackageName(parentPackageName);
       }
       return Optional.absent();
     }
diff --git a/value-processor/src/org/immutables/value/processor/meta/SourceNames.java b/value-processor/src/org/immutables/value/processor/meta/SourceNames.java
index 6cc5ec4d..23bfb25b 100644
--- a/value-processor/src/org/immutables/value/processor/meta/SourceNames.java
+++ b/value-processor/src/org/immutables/value/processor/meta/SourceNames.java
@@ -46,7 +46,10 @@ final class SourceNames {
   }
 
   static String parentPackageName(PackageElement element) {
-    String qualifiedName = element.getQualifiedName().toString();
+    return parentPackageName(element.getQualifiedName().toString());
+  }
+
+  static String parentPackageName(String qualifiedName) {
     int lastIndexOfDot = qualifiedName.lastIndexOf('.');
     if (lastIndexOfDot > 0) {
       return qualifiedName.substring(0, lastIndexOfDot);