List of usage examples for java.lang.reflect Field getInt
@CallerSensitive @ForceInline public int getInt(Object obj) throws IllegalArgumentException, IllegalAccessException
From source file:org.jasig.portal.tools.dbloader.TableXmlHandler.java
protected int getSqlType(final String sqlTypeName) { try {//from w ww . ja va 2 s.co m final Field sqlTypeField = Types.class.getField(sqlTypeName); return sqlTypeField.getInt(null); } catch (SecurityException e) { throw new RuntimeException("Cannot access field '" + sqlTypeName + "' on " + Types.class + " for column '" + this.currentColumn.getName() + "'", e); } catch (NoSuchFieldException e) { throw new IllegalArgumentException("No SQL Type field '" + sqlTypeName + "' on " + Types.class + " for column '" + this.currentColumn.getName() + "'", e); } catch (IllegalArgumentException e) { throw new RuntimeException("Cannot access field '" + sqlTypeName + "' on " + Types.class + " for column '" + this.currentColumn.getName() + "'", e); } catch (IllegalAccessException e) { throw new RuntimeException("Cannot access field '" + sqlTypeName + "' on " + Types.class + " for column '" + this.currentColumn.getName() + "'", e); } }
From source file:com.linkedin.pinot.integration.tests.ChaosMonkeyIntegrationTest.java
private int getProcessPid(Process process) { Class<? extends Process> clazz = process.getClass(); try {/*from w ww .j a v a 2 s .c om*/ Field field = clazz.getDeclaredField("pid"); field.setAccessible(true); return field.getInt(process); } catch (NoSuchFieldException e) { return -1; } catch (IllegalAccessException e) { return -1; } }
From source file:org.jasig.cas.util.annotation.GreaterThanAnnotationBeanPostProcessor.java
protected void processField(final Field field, final Annotation annotation, final Object bean, final String beanName) throws IllegalAccessException { final GreaterThan greaterThan = (GreaterThan) annotation; final int value = greaterThan.value(); final int val = field.getInt(bean); if (val <= value) { throw new FatalBeanException("value of field \"" + field.getName() + "\" must be greater than \"" + value + "\" on bean \"" + beanName + "\""); }/*from w w w . ja v a 2s .c om*/ }
From source file:org.springframework.integration.ftp.session.SessionFactoryTests.java
@Test public void testClientModes() throws Exception { DefaultFtpSessionFactory sessionFactory = new DefaultFtpSessionFactory(); Field[] fields = FTPClient.class.getDeclaredFields(); for (Field field : fields) { if (field.getName().endsWith("MODE")) { try { int clientMode = field.getInt(null); sessionFactory.setClientMode(clientMode); if (!(clientMode == FTPClient.ACTIVE_LOCAL_DATA_CONNECTION_MODE || clientMode == FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE)) { fail();//ww w .j a v a 2 s . co m } } catch (IllegalArgumentException e) { // success } catch (Throwable e) { fail(); } } } }
From source file:uk.ac.susx.tag.method51.core.organise.subprocess.JVMInstance.java
public void run(ProcessBuilder pb) throws IOException { Process process = pb.start(); //new StreamGobbler(process.getErrorStream()).start(); try {/*from w w w .j a v a 2s .c o m*/ Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true); int pid = f.getInt(process); writePid(pid); } catch (NoSuchFieldException | IllegalAccessException e) { LOG.error("Exception caught", e); } }
From source file:net.ftb.util.OSUtils.java
public static long getPID(Process process) { // windows/*from www . j a v a 2 s.c om*/ if (process.getClass().getName().equals("java.lang.Win32Process") || process.getClass().getName().equals("java.lang.ProcessImpl")) { long pid = -1; try { Field f = process.getClass().getDeclaredField("handle"); f.setAccessible(true); pid = Kernel32.INSTANCE.GetProcessId((Long) f.get(process)); } catch (Exception e) { pid = -1; Logger.logDebug("failed", e); } return pid; } if (process.getClass().getName().equals("java.lang.UNIXProcess")) { /* get the PID on unix/linux systems */ long pid = -1; try { Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true); pid = f.getInt(process); } catch (Throwable e) { pid = -1; Logger.logDebug("failed", e); } return pid; } Logger.logWarn("Unable to find getpid implementation"); return -1; }
From source file:com.comli.dawnbreaksthrough.personalintro.LicenseFragment.java
private List<Integer> getList() throws IllegalAccessException { List<Integer> list = new ArrayList<>(); Field[] fields = R.raw.class.getFields(); for (Field field : fields) { if (!field.isSynthetic() && !field.getName().equals("serialVersionUID")) { list.add(field.getInt(field)); }/*from www . j av a 2 s . com*/ } return list; }
From source file:org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.java
private boolean isValidTypes(int value) throws Exception { boolean result = false; for (Field field : Types.class.getFields()) { int curValue = field.getInt(null); if (curValue == value) { result = true;//from w ww. j av a2 s . c o m break; } } return result; }
From source file:com.github.jarlakxen.embedphantomjs.executor.PhantomJSConsoleExecutor.java
public int getPid() { if (process.getClass().getName().equals("java.lang.UNIXProcess")) { /* get the PID on unix/linux systems */ try {/* ww w. j av a2s . c o m*/ Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true); return f.getInt(process); } catch (Throwable e) { } } return -1; }
From source file:azkaban.jobExecutor.utils.process.AzkabanProcess.java
/** * Attempt to get the process id for this process * /*from www . ja v a2 s . c om*/ * @param process The process to get the id from * @return The id of the process */ private int processId(final java.lang.Process process) { int processId = 0; try { Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true); processId = f.getInt(process); } catch (Throwable e) { e.printStackTrace(); } return processId; }