diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java index 6bbea9f9af6f..62409ebaf80e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluatorImpl.java @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.ui.impl.watch; import com.intellij.compiler.CompilerConfiguration; @@ -23,7 +21,6 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.registry.Registry; -import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiCodeFragment; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -77,8 +74,8 @@ public class CompilingEvaluatorImpl extends CompilingEvaluator { JavaSdkVersion buildRuntimeVersion = runtime.getSecond(); // if compiler or debuggee version or both are unknown, let source and target be the compiler's defaults if (buildRuntimeVersion != null && debuggeeVersion != null) { - JavaSdkVersion minVersion = buildRuntimeVersion.ordinal() > debuggeeVersion.ordinal() ? debuggeeVersion : buildRuntimeVersion; - String sourceOption = getSourceOption(minVersion.getMaxLanguageLevel()); + JavaSdkVersion minVersion = debuggeeVersion.compareTo(buildRuntimeVersion) < 0 ? debuggeeVersion : buildRuntimeVersion; + String sourceOption = minVersion.getMaxLanguageLevel().getCompilerComplianceDefaultOption(); options.add("-source"); options.add(sourceOption); options.add("-target"); @@ -118,11 +115,6 @@ public class CompilingEvaluatorImpl extends CompilingEvaluator { return myCompiledClasses; } - @NotNull - private static String getSourceOption(@NotNull LanguageLevel languageLevel) { - return "1." + Integer.valueOf(3 + languageLevel.ordinal()); - } - private File generateTempSourceFile(File workingDir) throws IOException { Pair fileData = ReadAction.compute(() -> { PsiFile file = myData.getGeneratedInnerClass().getContainingFile(); diff --git a/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchCompilationSupport.java b/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchCompilationSupport.java index 3ba0b62b4d53..7e8cb539380d 100644 --- a/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchCompilationSupport.java +++ b/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchCompilationSupport.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.scratch; import com.intellij.compiler.options.CompileStepBeforeRun; @@ -161,7 +147,7 @@ public class JavaScratchCompilationSupport implements CompileTask { options.add("-g"); // always compile with debug info final JavaSdkVersion sdkVersion = JavaSdk.getInstance().getVersion(targetSdk); if (sdkVersion != null) { - final String langLevel = "1." + Integer.valueOf(3 + sdkVersion.getMaxLanguageLevel().ordinal()); + final String langLevel = sdkVersion.getMaxLanguageLevel().getCompilerComplianceDefaultOption(); options.add("-source"); options.add(langLevel); options.add("-target");