简体   繁体   中英

Windows GetClassName function returns the fully qualified class name of a JFrame

I have a Java application whose main window is a JFrame subclass.

There is a profiler attached which calls GetClassName for this Window, and it returns the fully qualified class, ie com.package.subpackage.MyClass, instead of SunAwtFrame.

I've never seen a class name like this returned before - the Java Application is being launched by Java WebStart - maybe there is a jnlp option for this? Anyone ever encountered this before?

Which JRE are you using? If you are using >1.4 then it will always return SunAwtFrame. This is in accordance to: https://www.java.net//node/659065

Thanks. -Promod

History of Java MSWindow class name

Java 1.1.7 "AwtFrame" changes to prefixed "SunAwtFrame" https://bugs.openjdk.java.net/browse/JDK-4131094

Java 1.4.0 After a complaint awt_frame::getClassName() changes to return the fully qualified java class name https://bugs.openjdk.java.net/browse/JDK-4284277

Java 1.4.0 Complaint to change back refused https://bugs.openjdk.java.net/browse/JDK-4486836

Java 1.6.0 A hard bug caused by the change convinces the dev to revert back to static name "SunAwtFrame" https://bugs.openjdk.java.net/browse/JDK-4846680

What the bug was: Creating a class that is called Edit or edit and extends JFrame and displaying the frame, the application shows a blinking cursor in the top left corner. Using the mouse to select the position of the cursor, the text used in setTitle is displayed on a white background.

The messy code in java 4 and 5:
LPCTSTR AwtFrame::GetClassName() {
! 
! if (m_windowClassName == NULL)
! {
! JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
! if (env->EnsureLocalCapacity(2) < 0) {
! m_windowClassName = new TCHAR[_tcslen(AWT_FRAME_WINDOW_CLASS_NAME) + 1];
! _tcscpy(m_windowClassName,AWT_FRAME_WINDOW_CLASS_NAME);
! }
! else
! {
! jobject frame = GetTarget(env);
! jclass frameClass = env->GetObjectClass(frame);
! 
! JavaStringBuffer jsb = JavaStringBuffer(env,JVM_GetClassName(env,frameClass));
! 
! m_windowClassName = new TCHAR[_tcslen(jsb) + 1];
! _tcscpy(m_windowClassName,jsb);
! 
! env->DeleteLocalRef(frameClass);
! env->DeleteLocalRef(frame);
! 
! }
! }
! return m_windowClassName;
  }


The current code since java 6:
  LPCTSTR AwtFrame::GetClassName() {
! return AWT_FRAME_WINDOW_CLASS_NAME;
  }  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM