Add test utility to scan for Structure.getFieldOrder() issues.
Esse commit está contido em:
@@ -243,6 +243,7 @@
|
||||
<fileset dir="lib">
|
||||
<include name="junit.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="lib/test"/>
|
||||
<pathelement path="${classes}"/>
|
||||
</path>
|
||||
</path>
|
||||
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -0,0 +1,50 @@
|
||||
package com.sun.jna;
|
||||
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.ResourcesScanner;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Utility class for detecting missing {@link com.sun.jna.Structure#getFieldOrder()} methods.
|
||||
*
|
||||
* This class could be moved to the unit test tree, but them reusing it in the 'platform' project would require
|
||||
* publishing this test tree.
|
||||
*
|
||||
* @author Dan Rollo
|
||||
* Date: 1/17/13
|
||||
* Time: 4:08 PM
|
||||
*/
|
||||
public final class StructureFieldOrderInspector {
|
||||
|
||||
private StructureFieldOrderInspector(){}
|
||||
|
||||
/**
|
||||
* Find all classes that extend {@link Structure}.
|
||||
*/
|
||||
public static Set<Class<Structure>> findStructureSubClasses(final ClassLoader classLoader) {
|
||||
|
||||
// @todo use: http://code.google.com/p/reflections/
|
||||
|
||||
List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
|
||||
classLoadersList.add(ClasspathHelper.contextClassLoader());
|
||||
classLoadersList.add(ClasspathHelper.staticClassLoader());
|
||||
|
||||
Reflections reflections = new Reflections(new ConfigurationBuilder()
|
||||
.setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
|
||||
.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
|
||||
.filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("org.your.package"))));
|
||||
|
||||
//Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
|
||||
Set<Class<Structure>> classes = (Set<Class<Structure>>) reflections.getSubTypesOf(Structure.class);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.sun.jna;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: dan
|
||||
* Date: 1/17/13
|
||||
* Time: 4:29 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class StructureFieldOrderInspectorTest {
|
||||
}
|
||||
Referência em uma Nova Issue
Bloquear um usuário