Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,7 @@ private int getJavaVersion() {
}

if (javaHome == null) {
String javaVersion = System.getProperty("java.specification.version");
int dot = javaVersion.indexOf('.');
if (dot > 0) {
javaVersion = javaVersion.substring(0, dot);
}
return Integer.parseInt(javaVersion);
return Runtime.version().feature();
} else {
return getJavaMajorVersion(javaHome);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DefaultJavaRuntimeManager implements JavaRuntimeManager {
})
public DefaultJavaRuntimeManager() {
File javaHome = new File(System.getProperty("java.home")); //NOI18N
String javaVersion = System.getProperty("java.specification.version"); //NOI18N
int javaVersion = Runtime.version().feature();
JavaRuntime defaultRuntime = JavaRuntimeManager.createJavaRuntime(DEFAULT_RUNTIME_ID, Bundle.DEFAULT_JAVA_RUNTIME_NAME(javaVersion), javaHome);

defaultRuntimes = Collections.singletonMap(DEFAULT_RUNTIME_ID, defaultRuntime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,8 @@ public class DebugTreeView extends BeanTreeView {
tree.setCellRenderer(rend);

setBackground(tree.getBackground());
if (System.getProperty("java.version").startsWith("1.6") &&
"GTK".equals(UIManager.getLookAndFeel().getID())) {
// leave the tree as opaque to paint the whole area
} else {
tree.setOpaque(false);
((JComponent)tree.getParent()).setOpaque(false);
}
tree.setOpaque(false);
((JComponent)tree.getParent()).setOpaque(false);
((JComponent)tree.getParent()).setBackground(tree.getBackground());
setWheelScrollingEnabled(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.netbeans.modules.debugger.jpda.models.ShortenedStrings.StringInfo;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.Actions;
import org.openide.awt.Mnemonics;
import org.openide.filesystems.FileChooserBuilder;
import org.openide.util.NbBundle;
Expand All @@ -51,37 +50,10 @@
*/
class BigStringCustomEditor extends JPanel implements ActionListener {

static final int MAX_STRING_LENGTH;
static final int MAX_STRING_LENGTH = AbstractObjectVariable.MAX_STRING_LENGTH;

private final StringInfo shortenedInfo;
private final String fullString;

static {
int maxStringLength = AbstractObjectVariable.MAX_STRING_LENGTH;
String javaV = System.getProperty("java.version");
if (javaV.startsWith("1.8.0")) {
String update = "";
for (int i = "1.8.0_".length(); i < javaV.length(); i++) {
char c = javaV.charAt(i);
if (Character.isDigit(c)) {
update += c;
} else {
break;
}
}
int updateNo = 0;
if (!update.isEmpty()) {
try {
updateNo = Integer.parseInt(update);
} catch (NumberFormatException nfex) {}
}
if (updateNo < 60) {
// Memory problem on JDK 8, fixed in update 60 (https://bugs.openjdk.java.net/browse/JDK-8072775):
maxStringLength = 1000;
}
}
MAX_STRING_LENGTH = maxStringLength;
}

private BigStringCustomEditor(Component delegateCustomEditor, StringInfo shortenedInfo, int preferredShortLength) {
this.shortenedInfo = shortenedInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public Mirror visitMethodInvocation(MethodInvocationTree arg0, EvaluationContext
} else if (type instanceof ClassType) {
cType = (ClassType) type;
} else {
if (JPDAUtils.IS_JDK_180_40 && (type instanceof InterfaceType) && isStatic) {
if ((type instanceof InterfaceType) && isStatic) {
cType = null;
iType = (InterfaceType) type;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,10 @@
* @author Jan Jancura
*/
public class JPDAUtils {
private static final String JAVA_VERSION = System.getProperty("java.version");
/**
* <code>true</code> when the current JDK version is 1.8.0 update 40, or newer.
*/
public static final boolean IS_JDK_180_40 = !JAVA_VERSION.startsWith("1.8.0") || // we know that it's 1.8.0 at least
getVersionUpdate(JAVA_VERSION) >= 40;


private static int getVersionUpdate(String javaVersion) {
if (javaVersion.length() < 7) {
return 0;
}
String update = javaVersion.substring(6);
try {
return Integer.parseInt(update);
} catch (NumberFormatException nfex) {
return 0;
}
}
public static final boolean IS_JDK_180_40 = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: deprecate


public static final ReferenceType getPreferredReferenceType(List<ReferenceType> referenceTypes, Logger logger) throws VMDisconnectedExceptionWrapper {
ReferenceType preferredType; // The preferred reference type from the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ public final class SingleSourceFileUtil {
// TODO this checks the runtime JDK of NB!
public static int findJavaVersion() throws NumberFormatException {
// JEP-330 is supported only on JDK-11 and above.
String javaVersion = System.getProperty("java.specification.version"); //NOI18N
if (javaVersion.startsWith("1.")) { //NOI18N
javaVersion = javaVersion.substring(2);
}
int version = Integer.parseInt(javaVersion);
return version;
return Runtime.version().feature();
}

public static final String GLOBAL_VM_OPTIONS = "java_file_launcher_global_vm_options"; //NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class EnablePreviewSingleSourceFile implements PreviewEnabler {

private static final String FILE_VM_OPTIONS = "single_file_vm_options"; //NOI18N

private FileObject file;
private final FileObject file;

private EnablePreviewSingleSourceFile(@NonNull FileObject file) {
Parameters.notNull("file", file); //NOI18N
Expand All @@ -68,7 +68,7 @@ public void enablePreview(String newSourceLevel) throws Exception {
Matcher m = SOURCE_FLAG_PATTERN.matcher(compilerArgs);

if (newSourceLevel == null) {
newSourceLevel = getJdkRunVersion();
newSourceLevel = Integer.toString(Runtime.version().feature());
}

if (compilerArgs.contains(SOURCE_FLAG)) {
Expand Down Expand Up @@ -138,15 +138,6 @@ public Void run() throws IOException {
}
}

private static String getJdkRunVersion() {
String javaVersion = System.getProperty("java.specification.version"); //NOI18N
if (javaVersion.startsWith("1.")) { //NOI18N
javaVersion = javaVersion.substring(2);
}

return javaVersion;
}

@ServiceProvider(service=Factory.class)
public static final class FactoryImpl implements Factory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package org.netbeans.modules.java.lsp.server.singlesourcefile;

import com.google.gson.JsonPrimitive;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.netbeans.api.annotations.common.NonNull;
Expand Down Expand Up @@ -85,12 +83,7 @@ public void enablePreview(String newSourceLevel) throws Exception {
}

private static String getJdkRunVersion() {
String javaVersion = System.getProperty("java.specification.version"); //NOI18N
if (javaVersion.startsWith("1.")) { //NOI18N
javaVersion = javaVersion.substring(2);
}

return javaVersion;
return Integer.toString(Runtime.version().feature());
}

@ServiceProvider(service=Factory.class, position=10_000_000)
Expand Down
8 changes: 0 additions & 8 deletions java/java.source.base/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@
<implementation-version/>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.asm</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>5.4</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.libs.javacapi</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@
*/
package org.netbeans.modules.java.source;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.lang.model.SourceVersion;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.openide.modules.OnStart;

/**
*
Expand All @@ -52,56 +44,4 @@ public static boolean hasWorkingJavac() {
return HAS_WORKING_JAVAC;
}

// safety net if someone manages to start NB on JDK 8 with nb-javac uninstalled
@OnStart
public static class FixClasses implements Runnable {

@Override
public void run() {
if (!hasWorkingJavac()) {
String JavaVersion = System.getProperty("java.specification.version"); //NOI18N
boolean isJdkVer8OrBelow = true;
if (!JavaVersion.startsWith("1.")) { //NOI18N
isJdkVer8OrBelow = false;
}
if (isJdkVer8OrBelow) {
{
ClassWriter w = new ClassWriter(0);
w.visit(Opcodes.V1_8, Opcodes.ACC_ABSTRACT | Opcodes.ACC_PUBLIC, "com/sun/tools/javac/code/Scope$WriteableScope", null, "com/sun/tools/javac/code/Scope", null);
byte[] classData = w.toByteArray();

defineClass("com.sun.tools.javac.code.Scope$WriteableScope",
"com.sun.tools.javac.code.Scope",
classData);
}
{
ClassWriter w = new ClassWriter(0);
w.visit(Opcodes.V1_8, Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE | Opcodes.ACC_PUBLIC, "javax/lang/model/element/ModuleElement", null, "java/lang/Object", new String[] {"javax/lang/model/element/Element"});
byte[] classData = w.toByteArray();

defineClass("javax.lang.model.element.ModuleElement",
"com.sun.tools.javac.code.Scope",
classData);
}
}
}
}

private void defineClass(String fqn, String injectToClass, byte[] classData) {
try {
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
Field theUnsafe = unsafeClass.getDeclaredField("theUnsafe"); //NOI18N
theUnsafe.setAccessible(true);
Object unsafe = theUnsafe.get(null);

Class targetClass = Class.forName(injectToClass); //NOI18N

Method defineClass = unsafeClass.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class, ClassLoader.class, ProtectionDomain.class); //NOI18N
defineClass.invoke(unsafe, fqn, classData, 0, classData.length, targetClass.getClassLoader(), targetClass.getProtectionDomain()); //NOI18N
} catch (Throwable t) {
//ignore...
Logger.getLogger(NoJavacHelper.class.getName()).log(Level.WARNING, null, t);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,6 @@ private static void closeToolbar(String menu){
mainWindow.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
}
}

/**
* Work around issue 35962 (Main menu popup accidentally rolled up)
* Issue has been fixed for JDK 1.5, so we will use it only for JDK 1.4.X
*/
public static void workarroundMainMenuRolledUp() {
if(System.getProperty("java.version").indexOf("1.4") != -1) {
String helpMenu = Bundle.getStringTrimmed("org.netbeans.core.Bundle","Menu/Help") + "|" + Bundle.getStringTrimmed("org.netbeans.core.actions.Bundle" , "About");
String about = Bundle.getStringTrimmed("org.netbeans.core.Bundle_nb", "CTL_About_Title");

new ActionNoBlock(helpMenu, null).perform();
new NbDialogOperator(about).close();
}
}

public static String jEditProjectOpen() {

Expand Down
Loading
Loading