Quake Live背后的技术是什么?(What are the technologies behind Quake Live?)
Quake Live使用了哪些技术?
具体来说,如何创建一个在浏览器中广泛使用3D的Web应用程序? 该服务要求您下载并安装插件才能播放。 如何创建这样的插件,以及它如何与网站交互?
What technologies are used to power Quake Live?
Specifically, how do you create a web application that makes such extensive use of 3D in the browser? The service requires you to download and install a plug-in in order to play. How do you create such a plug-in, and how does it interact with the web site?
原文:https://stackoverflow.com/questions/3259768
最满意答案
这是不可能的,至少不是你所问的一般意义上的。
没有
B.getName()
方法。 虽然您可以在代码中键入它,但它将被编译为与A.getName()
相同的字节码(我认为您也会收到编译器警告)。因此,在运行时,无法告诉某人是如何引用静态方法的 - 就像没有办法告诉调用者使用的局部变量名称一样。
This is not possible, at least not in the general sense that you've asked.
There is no method
B.getName()
. While you can type that in code, it will be compiled to identical bytecode toA.getName()
(and I think you get a compiler warning too).Thus at runtime, there is no way to tell how someone referenced the static method - just as there's no way to tell what local variable names a caller is using.
相关问答
更多-
为了正确地重构(重命名类),那么你应该使用: MyClass.class.getName(); // full name with package 或(感谢@James Van Huis ): MyClass.class.getSimpleName(); // class name and no more In order to support refactoring correctly (rename class), then you should use either: MyClass.cla ...
-
尝试添加 PowerMockito.mockStatic(A.class); PowerMockito.mockStatic(B.class); 但我会重构代码并使用com.google.inject.Provider来创建B类的实例。 很容易嘲笑它,你不需要PowerMockito。 更新。 这段代码对我来说是正确的(我在A类中添加了getter) package main; import org.junit.Assert; import org.junit.Test; import org.ju ...
-
我会尝试以下方法: public class ParentClass { } public class ChildClass : ParentClass { } public static class StaticClass { public static void SomeMethod(ParentClass d) { var t = d.GetType(); } } public class StaticChildren { public void ...
-
是的,当你调用static方法时会加载类字节代码(但是一次 ,而不是每次都加载)。当你调用非静态方法时也会发生同样的情况。 在后一种情况下,还必须创建一个实例。 因此,就你的问题而言,这是一种错误的二分法。 因为Java是一种动态语言和平台(使用JIT),所以在方法调用之间运行时效率会显着提高。 因此,最好编写清晰简洁的代码(即Write Dumb Code )。 如果实现解决方案的最清晰方法是static方法,那么使用它们。 True, the class byte-code is loaded when ...
-
泛型类的类在运行时不可用,即T.class没有意义。 泛型类型在编译时被转换为Object 。 这就是所谓的Type Erasure 。 如果您确实需要类型参数的class ,则需要将其添加为参数: public abstract class Model
{ public static T find(Class clazz, int id) { T result = (T) blackMagicMethod(clazz, id); return ... -
这是不可能的,至少不是你所问的一般意义上的。 没有B.getName()方法。 虽然您可以在代码中键入它,但它将被编译为与A.getName()相同的字节码(我认为您也会收到编译器警告)。 因此,在运行时,无法告诉某人是如何引用静态方法的 - 就像没有办法告诉调用者使用的局部变量名称一样。 This is not possible, at least not in the general sense that you've asked. There is no method B.getName(). Whi ...
-
您不能在Java中覆盖静态方法,因此通过子类对静态方法的任何调用都将在编译时绑定到基类。 因此,在运行应用程序之前,对B.testMethod()的调用将绑定到A.testMethod。 由于您在运行时查找信息,因此通过普通的Java操作无法使用它。 You cannot override static methods in Java, so any calls to the static method via a subclass will be bound to the base class at co ...
-
QObject::staticMetaObject应该做的。 QObject::staticMetaObject should do the trick.
-
JAVA:了解调用静态方法的方法/类(JAVA: Knowing the Method/Class from where a static method was called)[2022-07-14]
您可以在Util.method使用Thread.currentThread().getStackTrace() 。 要在Util.method之前获得最后一个调用,您可以执行以下操作: public class Util { ... public static void method() { StackTraceElement[] st = Thread.currentThread().getStackTrace(); //st[0] is the call of getStackTra ... -
静态类变量是在调用静态方法时创建的 - Java(Static class variables are created when Static methods are being called - Java)[2023-05-18]
那是因为你第一次触摸一个类 (调用一个方法,访问一个字段或创建一个对象),所有静态字段都将被初始化 。 这是由Java语言规范保证的,你不能真正做很多事情: 将修改器更改为非静态或 懒洋洋地初始化你的观点 That's because the first time you will touch a class (calling a method, accessing a field or creating an object) all the static fields will be initialize ...