JDK-8162704 : deeply nested expression stumps the compiler-checking algorithm
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2016-07-26
  • Updated: 2017-02-14
  • Resolved: 2017-02-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Duplicate :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
for generated code of the form (A.concat(B)).concat(C.concat(D)) 

which forms a balanced tree but much deeper
where the leafs all of the same form and the leafs  are of the form new CharString(RB, <string_literal>)

seems to break the checking algorithm of Javac from JAVA SE 8 

While the code is successfully compilable in Java 7 in 2-3 seconds, Javac 8 does not finish checking in over 90 minutes! (I have not checked this further and I am not sure whether it will finish at all or run out of resources)

JUSTIFICATION :
If the compiler even finishes, this would be a huge performance loss for a very simple case of code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The performance should be comparable to the one in earlier versions of javac.
ACTUAL -
When running javac with -verbose, the last statement printed is: [checking TTCN3_spv_nos].

One CPU is used to the maximum, memory is used and freed continually (when monitoring the process with jvisualvm). Reserved memory on the process level continually increases.

Unfortunately, it is only reproducible when using our runtime library which that generated code is compiled against. I would provide this in jar-form, if requested.

When replacing the imported classes with local classes, the problem does not occur, so it might have to do something with name resolution.

I have whittled the original example down to something where the javac 8 only takes 10 times more time than javac 7, but the performance loss does not seem to be linear to the size of the input, but either polynomial or even exponential.

---------- BEGIN SOURCE ----------
import java.util.Arrays;
import java.util.Collection;
import java.math.BigInteger;
import java.math.BigDecimal;
import de.tu_berlin.cs.uebb.ttcn.runtime.*;
import de.tu_berlin.cs.uebb.ttcn.runtime.Void;
import de.tu_berlin.cs.uebb.muttcn.runtime.*;
import de.tu_berlin.cs.uebb.muttcn.runtime.Float;
import de.tu_berlin.cs.uebb.ttcn.runtime.continuous.*;
import de.tu_berlin.cs.uebb.muttcn.runtime.Module;
import com.testingtech.ttcn.tci.ExtendedTciTypeClass;
import com.testingtech.ttcn.tciext.EnumeratedType;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
import org.etsi.ttcn.tci.IntegerValue;
import de.tu_berlin.cs.uebb.muttcn.runtime.RB;

public class TTCN3_spv_nos_small1 extends ModuleEnvironment {
  public static CharString TTCN3_spv_nos;

  public
    TTCN3_spv_nos_small1(final RB RB, final Module module) {
    super(RB, module);
    TTCN3_spv_nos =
                 new
                       CharString(RB,
                                  "")
                     .concat(new CharString(RB, ""))
                     .concat(new
                               CharString(RB,
                                          "")
                             .concat(new CharString(RB, "")))
                     .concat(new CharString(RB, "")
                             .concat(new
                                       CharString(RB,
                                                  ""))
                             .concat(new
                                       CharString(RB,
                                                  "")
                                     ))
                             .concat(new
                                       CharString(RB, "")
                                     .concat(new
                                               CharString(RB,
                                                          "")
                                             .concat(new
                                                       CharString(RB,
                                                                  ""))
                                             .concat(new
                                                       CharString(RB,
                                                                  "")
                                                     .concat(new
                                                               CharString(RB,
                                                                          "")))
                                             .concat(new
                                                       CharString(RB,
                                                                  "")
                                                     .concat(new
                                                               CharString(RB,
                                                                          ""))
                                                     .concat(new
                                                               CharString(RB,
                                                                          "")
                                                             .concat(new
                                                                       CharString(RB,
                                                                                  "")
                                                                     .concat(new
                                                                               CharString(RB,
                                                                                          ""))))
                                                     .concat(new
                                                               CharString(RB,
                                                                          "")
                                                             .concat(new
                                                                       CharString(RB,
                                                                                  ""))
                                                             .concat(new
                                                                       CharString(RB,
                                                                                  "")
                                                                     .concat(new
                                                                               CharString(RB,
                                                                                          "")
                                                                             .concat(new
                                                                                       CharString(RB,
                                                                                                  ""))))
                                                             .concat(new
                                                                       CharString(RB,
                                                                                  "")
                                                                     .concat(new
                                                                               CharString(RB,
                                                                                          ""))
                                                                     .concat(new
                                                                               CharString(RB,
                                                                                          "")
                                                                             .concat(new
                                                                                       CharString(RB,
                                                                                                  "")
                                                                                     .concat(new
                                                                                               CharString(RB,
                                                                                                          ""))))
                                                                     .concat(new
                                                                               CharString(RB,
                                                                                          "")
                                                                             .concat(new
                                                                                       CharString(RB,
                                                                                                  ""))
                                                                             .concat(new
                                                                                       CharString(RB,
                                                                                                  "")
                                                                                     .concat(new
                                                                                               CharString(RB,
                                                                                                          "")
                                                                                             .concat(new
                                                                                                       CharString(RB,
                                                                                                                  ""))))))))));
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
I will generate the code in a different way so that literal strings are concatenated already at compile-time. For my special case, this will solve the problem.


Comments
This found as issue in 8u and javac works fine in 7u and 9 ea b-127 Below are compilation time taken by javac == 7uxx - 936ms (Pass) 8uxx - 13261741ms (Fail) // 8u is taking almost 3 hours 9 ea b-127 - 994ms (Pass) == Result of javac 0n 8u102 in verbose mode == -sh-4.1$ /opt/java/jdk1.8.0_102/bin/javac -verbose -cp ./TTthreeRuntimeApi.jar:./TTthreeRuntime.jar TTCN3_spv_nos.java [parsing started RegularFileObject[TTCN3_spv_nos.java]] [parsing completed 76ms] [search path for source files: ./TTthreeRuntimeApi.jar,./TTthreeRuntime.jar] [search path for class files: /opt/java/jdk1.8.0_102/jre/lib/resources.jar,/opt/java/jdk1.8.0_102/jre/lib/rt.jar,/opt/java/jdk1.8.0_102/jre/lib/sunrsasign.jar,/opt/java/jdk1.8.0_102/jre/lib/jsse.jar,/opt/java/jdk1.8.0_102/jre/lib/jce.jar,/opt/java/jdk1.8.0_102/jre/lib/charsets.jar,/opt/java/jdk1.8.0_102/jre/lib/jfr.jar,/opt/java/jdk1.8.0_102/jre/classes,/opt/java/jdk1.8.0_102/jre/lib/ext/dnsns.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/zipfs.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/cldrdata.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/localedata.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/sunjce_provider.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/jaccess.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/nashorn.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/sunpkcs11.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/sunec.jar,/opt/java/jdk1.8.0_102/jre/lib/ext/jfxrt.jar,./TTthreeRuntimeApi.jar,./TTthreeRuntime.jar] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/util/Arrays.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/util/Collection.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/math/BigInteger.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/math/BigDecimal.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/ttcn/runtime/Void.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/Float.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/Module.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(com/testingtech/ttcn/tci/ExtendedTciTypeClass.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(com/testingtech/ttcn/tciext/EnumeratedType.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/Type.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/Value.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/IntegerValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/RB.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/ModuleEnvironment.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/RuntimeEnvironment.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/ttcn/runtime/CharString.class)]] [checking TTCN3_spv_nos] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/io/Serializable.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/ttcn/runtime/BaseCharString.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/List.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/ValueImpl.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/TciValueTemplate.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/ttcn/runtime/TTCNObject.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/CharstringValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/DecodableValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/CharacterPattern.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(com/testingtech/ttcn/tciext/ExtendedStringValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(com/testingtech/ttcn/tciext/ExtendedValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/BasicList.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Cloneable.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/BaseValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(com/testingtech/ttcn/tci/TciTemplate.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(com/testingtech/ttcn/tciext/DecodedValue.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(org/etsi/ttcn/tci/MatchingMechanism.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntimeApi.jar(com/testingtech/ttcn/tci/ValueWithLength.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/ttcn/runtime/CharStringReference.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Error.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/TestCaseError.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Byte.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Character.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Short.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Long.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Float.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Integer.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Double.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Boolean.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Void.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/ttcn/runtime/UniCharString.class)]] [loading ZipFileIndexFileObject[/opt/java/jdk1.8.0_102/lib/ct.sym(META-INF/sym/rt.jar/java/lang/String.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/Int.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/IntegerList.class)]] [loading ZipFileIndexFileObject[./TTthreeRuntime.jar(de/tu_berlin/cs/uebb/muttcn/runtime/Closure.class)]] [wrote RegularFileObject[TTCN3_spv_nos$1$1.class]] [wrote RegularFileObject[TTCN3_spv_nos$1.class]] [wrote RegularFileObject[TTCN3_spv_nos.class]] [total 13261741ms] Note: TTCN3_spv_nos.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. -sh-4.1$ javac is taking 3 hours to compile java files, in 7 and 9 it takes less then one second.This is issue found on 8uxx and exist in 8u101/102
28-07-2016

Issue reported on 8u92, requested submitter to share more information == Test case you have provided has following dependencies import de.tu_berlin.cs.uebb.ttcn.runtime.*; import de.tu_berlin.cs.uebb.ttcn.runtime.Void; import de.tu_berlin.cs.uebb.muttcn.runtime.*; import de.tu_berlin.cs.uebb.muttcn.runtime.Float; import de.tu_berlin.cs.uebb.ttcn.runtime.continuous.*; import de.tu_berlin.cs.uebb.muttcn.runtime.Module; import com.testingtech.ttcn.tci.ExtendedTciTypeClass; import com.testingtech.ttcn.tciext.EnumeratedType; import org.etsi.ttcn.tci.Type; import org.etsi.ttcn.tci.Value; import org.etsi.ttcn.tci.IntegerValue; import de.tu_berlin.cs.uebb.muttcn.runtime.RB; Could you please share individual test case or dependent files in zip format. ==
27-07-2016

Provided test case is not complete, it has dependencies with third party libraries import de.tu_berlin.cs.uebb.ttcn.runtime.*; import de.tu_berlin.cs.uebb.ttcn.runtime.Void; import de.tu_berlin.cs.uebb.muttcn.runtime.*; import de.tu_berlin.cs.uebb.muttcn.runtime.Float; import de.tu_berlin.cs.uebb.ttcn.runtime.continuous.*; import de.tu_berlin.cs.uebb.muttcn.runtime.Module; import com.testingtech.ttcn.tci.ExtendedTciTypeClass; import com.testingtech.ttcn.tciext.EnumeratedType; import org.etsi.ttcn.tci.Type; import org.etsi.ttcn.tci.Value; import org.etsi.ttcn.tci.IntegerValue; import de.tu_berlin.cs.uebb.muttcn.runtime.RB; Writing similar program to create this issue.
27-07-2016