- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用子 URLClassLoader
来加载可在运行时在 Android SDK (sdk/platforms/) 中找到的 android.jar,然后使用 Google Reflections 库来检查新的我加载的类。但是,似乎使用以下代码,我只能检查静态字段;我还想检查实例字段。 (不过我对方法没有任何问题!)
Path jarPath = fs.getPath("/android-sdk-macosx/platforms/android-10/android.jar");
URL[] urls = new URL[]{jarPath.toUri().toURL()};
Reflections r = new Reflections(new ConfigurationBuilder().setUrls(urls).setScanners(
new SubTypesScanner(false)
));
URLClassLoader cl = URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader());
for (String cls : r.getAllTypes()) {
System.out.println(cls);
Class<?> c = cl.loadClass(cls);
Field[] allFields = c.getDeclaredFields();
for (Field f : allFields) {
System.out.println('\t' + (f.getModifiers() & Modifier.STATIC) + " " + f.getName());
}
}
例如,当上面的代码检查 android.view.View
时,它只打印以下内容:
android.view.View
8 VIEW_LOG_TAG
8 NO_ID
8 VISIBLE
8 INVISIBLE
8 GONE
8 DRAWING_CACHE_QUALITY_LOW
8 DRAWING_CACHE_QUALITY_HIGH
8 DRAWING_CACHE_QUALITY_AUTO
8 SCROLLBARS_INSIDE_OVERLAY
8 SCROLLBARS_INSIDE_INSET
8 SCROLLBARS_OUTSIDE_OVERLAY
8 SCROLLBARS_OUTSIDE_INSET
8 KEEP_SCREEN_ON
8 SOUND_EFFECTS_ENABLED
8 HAPTIC_FEEDBACK_ENABLED
8 FOCUSABLES_ALL
8 FOCUSABLES_TOUCH_MODE
8 FOCUS_BACKWARD
8 FOCUS_FORWARD
8 FOCUS_LEFT
8 FOCUS_UP
8 FOCUS_RIGHT
8 FOCUS_DOWN
8 EMPTY_STATE_SET
8 ENABLED_STATE_SET
8 FOCUSED_STATE_SET
8 SELECTED_STATE_SET
8 WINDOW_FOCUSED_STATE_SET
8 ENABLED_FOCUSED_STATE_SET
8 ENABLED_SELECTED_STATE_SET
8 ENABLED_WINDOW_FOCUSED_STATE_SET
8 FOCUSED_SELECTED_STATE_SET
8 FOCUSED_WINDOW_FOCUSED_STATE_SET
8 SELECTED_WINDOW_FOCUSED_STATE_SET
8 ENABLED_FOCUSED_SELECTED_STATE_SET
8 ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
8 ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_SELECTED_STATE_SET
8 PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_FOCUSED_STATE_SET
8 PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_FOCUSED_SELECTED_STATE_SET
8 PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_ENABLED_STATE_SET
8 PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_ENABLED_SELECTED_STATE_SET
8 PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_ENABLED_FOCUSED_STATE_SET
8 PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
8 PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET
8 PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
8 OVER_SCROLL_ALWAYS
8 OVER_SCROLL_IF_CONTENT_SCROLLS
8 OVER_SCROLL_NEVER
But there is obviously more to it!
我做错了什么?
最佳答案
将 jar 文件通过反编译器后,结果发现 SDK 中的 android.jar 只是一个空壳,因此 Eclipse 和 IntelliJ 等 IDE 可以使用较小的 jar 来帮助自动完成。代码很好,但我需要检查完整的 jar 。我找到了一个托管这些完整 jar 的 Github 存储库:https://github.com/Sable/android-platforms ,如果有人感兴趣的话。
关于java - 如何使用反射来检查使用不同类加载器加载的类的非静态字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27772526/
所以我有这个 UltraTicTacToe 游戏,我正在用 HTML/CSS/JS 编码。它由表中表中的表组成。当您单击 X 或 O 时,我想要突出显示您应该进入的下一个 TicTacToe 牌 ta
Some text Some more text 如何让每个 .example 的 .whatever 包含其 .test 的内容? 例如,如果代码是这样的: Som
我是一名优秀的程序员,十分优秀!