Java Code Examples for com.intellij.openapi.util.SystemInfo#IS_AT_LEAST_JAVA9
The following examples show how to use
com.intellij.openapi.util.SystemInfo#IS_AT_LEAST_JAVA9 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WinProcessManager.java From consulo with Apache License 2.0 | 6 votes |
public static int getProcessId(Process process) { String processClassName = process.getClass().getName(); if (processClassName.equals("java.lang.Win32Process") || processClassName.equals("java.lang.ProcessImpl")) { try { if (SystemInfo.IS_AT_LEAST_JAVA9) { //noinspection JavaReflectionMemberAccess return ((Long)Process.class.getMethod("pid").invoke(process)).intValue(); } long handle = assertNotNull(ReflectionUtil.getField(process.getClass(), process, long.class, "handle")); return Kernel32.INSTANCE.GetProcessId(new WinNT.HANDLE(Pointer.createConstant(handle))); } catch (Throwable t) { throw new IllegalStateException("Failed to get PID from instance of " + process.getClass() + ", OS: " + SystemInfo.OS_NAME, t); } } throw new IllegalStateException("Unable to get PID from instance of " + process.getClass() + ", OS: " + SystemInfo.OS_NAME); }
Example 2
Source File: UnixProcessManager.java From consulo with Apache License 2.0 | 5 votes |
public static int getProcessId(@Nonnull Process process) { try { if (SystemInfo.IS_AT_LEAST_JAVA9 && "java.lang.ProcessImpl".equals(process.getClass().getName())) { //noinspection JavaReflectionMemberAccess return ((Long)Process.class.getMethod("pid").invoke(process)).intValue(); } return assertNotNull(ReflectionUtil.getField(process.getClass(), process, int.class, "pid")); } catch (Throwable t) { throw new IllegalStateException("Failed to get PID from instance of " + process.getClass() + ", OS: " + SystemInfo.OS_NAME, t); } }
Example 3
Source File: ByteArrayCharSequence.java From consulo with Apache License 2.0 | 5 votes |
/** * @return instance of {@link ByteArrayCharSequence} if the supplied string can be stored internally * as a byte array of 8-bit code points (for more compact representation); its {@code string} argument otherwise */ @Nonnull @ReviewAfterMigrationToJRE(9) public static CharSequence convertToBytesIfPossible(@Nonnull CharSequence string) { if (SystemInfo.IS_AT_LEAST_JAVA9) return string; // see JEP 254: Compact Strings if (string.length() == 0) return ""; if (string instanceof ByteArrayCharSequence) return string; byte[] bytes = toBytesIfPossible(string); return bytes == null ? string : new ByteArrayCharSequence(bytes); }
Example 4
Source File: PreJava9UIUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Object AA_TEXT_PROPERTY_KEY() { if (SystemInfo.IS_AT_LEAST_JAVA9) { throw new IllegalArgumentException("java 9 restricted"); } return ourAATextPropertyKey.getValue(); }
Example 5
Source File: PreJava9UIUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Object newAATextInfo(Object hint, Integer value) { if (SystemInfo.IS_AT_LEAST_JAVA9) { throw new IllegalArgumentException("java 9 restricted"); } try { return ourAATextInfoConstructor.getValue().newInstance(hint, value); } catch (Exception e) { throw new RuntimeException(e); } }
Example 6
Source File: GraphicsUtil.java From consulo with Apache License 2.0 | 5 votes |
@ReviewAfterMigrationToJRE(9) public static void setAntialiasingType(@Nonnull JComponent list, AntialiasingType type) { if(SystemInfo.IS_AT_LEAST_JAVA9) { list.putClientProperty(RenderingHints.KEY_TEXT_ANTIALIASING, type.getHint()); list.putClientProperty(RenderingHints.KEY_TEXT_LCD_CONTRAST, UIUtil.getLcdContrastValue()); } else { if(type.isEnabled()) { list.putClientProperty(PreJava9UIUtil.AA_TEXT_PROPERTY_KEY(), PreJava9UIUtil.newAATextInfo(type.getHint(), UIUtil.getLcdContrastValue())); } else { list.putClientProperty(PreJava9UIUtil.AA_TEXT_PROPERTY_KEY(), null); } } }