java.lang.NoSuchMethodError: accessibilityHitTest - java

I am getting this error on my M1 Mac. I am running a simple GUI program in Eclipse for a class and getting the error: "Bad JNI lookup accessibilityHitTest" followed by 32 lines of red messages and "Exception in thread "AppKit Thread" java.lang.NoSuchMethodError: accessibilityHitTest". I installed Java OpenJDK 17.0.1 through Homebrew, which is the up-to-date version according to homebrew. I do not know how to program in Java and this is my first class learning the language so I am a bit over my head at the moment, but this is the in-class example code that is supposed to be very simple so I am beyond confused as to why this is happening. Thank you to anyone that can provide any help in this situation!
This is what I get from the console window:
2023-02-12 07:50:17.847 java[10456:90865] Bad JNI lookup accessibilityHitTest
2023-02-12 07:50:17.849 java[10456:90865] (
0 libawt_lwawt.dylib 0x000000010dcfc7d1 -[JavaComponentAccessibility accessibilityHitTest:withEnv:] + 153
1 libawt_lwawt.dylib 0x000000010dcad7e2 -[AWTView accessibilityHitTest:] + 179
2 AppKit 0x00007ff81322ff47 -[NSWindow(NSWindowAccessibility) accessibilityHitTest:] + 302
3 AppKit 0x00007ff812cfe5ad -[NSApplication(NSApplicationAccessibility) accessibilityHitTest:] + 285
4 AppKit 0x00007ff812cbf46b CopyElementAtPosition + 138
5 HIServices 0x00007ff8150cb505 _AXXMIGCopyElementAtPosition + 402
6 HIServices 0x00007ff8150ed194 _XCopyElementAtPosition + 355
7 HIServices 0x00007ff8150aa5a9 mshMIGPerform + 182
8 CoreFoundation 0x00007ff80f8483f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
9 CoreFoundation 0x00007ff80f848337 __CFRunLoopDoSource1 + 536
10 CoreFoundation 0x00007ff80f846fb6 __CFRunLoopRun + 2749
11 CoreFoundation 0x00007ff80f845e7f CFRunLoopRunSpecific + 560
12 HIToolbox 0x00007ff8196d8766 RunCurrentEventLoopInMode + 292
13 HIToolbox 0x00007ff8196d8576 ReceiveNextEventCommon + 679
14 HIToolbox 0x00007ff8196d82b3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
15 AppKit 0x00007ff8128d1293 _DPSNextEvent + 909
16 AppKit 0x00007ff8128d0114 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
17 libosxapp.dylib 0x000000010d920653 -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 121
18 AppKit 0x00007ff8128c2757 -[NSApplication run] + 586
19 libosxapp.dylib 0x000000010d920431 +[NSApplicationAWT runAWTLoopWithApp:] + 165
20 libawt_lwawt.dylib 0x000000010dd047a1 +[AWTStarter starter:headless:] + 496
21 libosxapp.dylib 0x000000010d921f73 +[ThreadUtilities invokeBlockCopy:] + 15
22 Foundation 0x00007ff8105fd190 __NSThreadPerformPerform + 177
23 CoreFoundation 0x00007ff80f847ed1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x00007ff80f847e80 __CFRunLoopDoSource0 + 157
25 CoreFoundation 0x00007ff80f847c4e __CFRunLoopDoSources0 + 212
26 CoreFoundation 0x00007ff80f8468a8 __CFRunLoopRun + 943
27 CoreFoundation 0x00007ff80f845e7f CFRunLoopRunSpecific + 560
28 libjli.dylib 0x000000010d3a989d CreateExecutionEnvironment + 381
29 libjli.dylib 0x000000010d3a5b45 JLI_Launch + 1253
30 java 0x0000000104dd1c15 main + 363
31 dyld 0x0000000205073310 start + 2432
)
Exception in thread "AppKit Thread" java.lang.NoSuchMethodError: accessibilityHitTest
Hello from the actionPerformed() method!
The button has been pressed.
Below is the code I am trying to get to work. It does launch a basic GUI with all three fields but gives me the above-mentioned error whenever I press the button or type into the text box. Also, for some weird reason, the button does not show up as red, but the text box is highlighted in yellow. The java.awt.Color library appears to be working because it is correct for the text box but no matter what I do to get the button to show up in a color it remains a white background. The color chosen is arbitrary and all works for the text box but nothing whatsoever with the button.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyFirstGUI implements ActionListener
{
public static void main(String[] args)
{
new MyFirstGUI(); // load self!
}
JFrame window = new JFrame("This is my first GUI program");
JButton button = new JButton("Push me!");
JTextField textField = new JTextField("Enter data here and press ENTER.");
JTextArea textArea = new JTextArea("Info presented to user here.");
public MyFirstGUI() // CONSTRUCTOR (called by the "new" loader)
{
System.out.println("Hi from MyFirstGUI constructor!");
// Build the GUI
window.getContentPane().add(button, "North"); // top area
window.getContentPane().add(textArea,"Center");// middle area
window.getContentPane().add(textField,"South");// bottom area
window.setLocation(500,0); // x,y in "pixels" y=0 is top of window
window.setSize(500,500); // x,y
button.setBackground(Color.red);
textField.setBackground(Color.yellow);
textArea.setEditable(false); // keep cursor out
window.setVisible(true); // show it!
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
button.addActionListener(this); // call me when pushed!
textField.addActionListener(this);// call me when ENTER key!
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == button)
{
System.out.println("Button was pushed!");
}
if (ae.getSource() == textField)
{
System.out.println("TextField had data entry!");
String input = textField.getText();
textField.setText(""); // clear!
textArea.setText(input);
}
}
}
I have updated every possible piece of software and compared this to what I get on my Intel-based Mac. The issue is mostly solved using all the same software on that computer so this leads me to believe there is an issue running OpenJDK Java 17.0.1 on M1 Macs.
Possible complications to consider:
Is it that I am using an M1 Mac? This is what I think is the main concern…
If I run this on my old 2016 intel Mac running macOS Monterey 12.6.3 (the newest it can run) I can get it to run the GUI without error (but the red button still shows up white).
How can I get this to run properly on my M1 Mac?!? It is nice that I can get it running on my old laptop but it doesn't help solve the issue.
My professor is ancient and is probably using an older version of Java, if this is the case is there’d reason an older version of java would cause this problem?
This is just a question, I have no way of testing this.
Is this something to do with my software versions?
I updated to MacOS 13.2 Ventura and have updated home-brew, java, and eclipse. I do not think this is the issue but I am using pretty basic java software and simple code so I am not sure how many issues there could be.
Is it something to do with Eclipse?
I tested this by running the application in terminal and it acted exactly the same. The correct information displays on the GUI but no red button and the same error is happening.

Related

Buffered Writer occasionally creates symbols rather than numbers

So I have a program that collects a bunch of data and continuously concatenates the data into a string with a single white space between each entry. During my close routine I print the String into a txt file using buffered writer. About 50% of the time the data shows up as (mostly) Chinese symbols. Is the VM doing some weird Unicode stuff? Why does this only occur sometimes?
I've looked around on other forums and have not seen other instances of this problem. None of the other CS majors I know understand what is happening.
EDIT : the data is all integer numbers ranging 0-1365;
UPDATE: upon further research I found this which makes me think a may need a PrintStream rather than a BufferedWriter can anyone speak to that? I tested the PrintStream and I will not be able to construct it with a FileWriter as I would a BufferedWriter which means I need more research to write to my txt.
UPDATE: printing to the console does not make this error occur. I will accept an answer that explains way Notepad (the program I am using to open the txt) sometimes displays numbers and sometimes displays symbols.
Here is the relevant code:
//fields
private static BufferedWriter out;
private File saveFile;
String data;
//inside constructor
this.saveFile = new File("C:\\Users\\HPlaptop\\Desktop\\MouseData.txt");
this.saveFile.delete();
try{this.saveFile.createNewFile();}
catch (IOException e ){System.out.println("File creation error");}
try {out = new BufferedWriter(new FileWriter("C:\\Users\\HPlaptop\\Desktop\\MouseData.txt"));}
catch (IOException e) {System.out.println("IO Error");}
this.control.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ //there is a method call here but the basics are below
out.write(data);
out.close();
System.exit(0);
}
});
Here is an example data set printed correctly:
1365 767 1365 767 1365 767 1364 767 1353 756 1268 692 1114 604 980 488 812 334 744 283 694 244 593 150 473 81 328 13 207 0 124 0 115 0 102 0 99 6 107 13 132 20 173 32 187 31 190 25 194 20 201 17 215 14 221 10 224 7 224 7 224 7 226 6 226 6 226 6 226 6 226 6 226 6 226 6
This data set was taken seconds later and is not what I want
㐀ㄹ㈠㤰㐠㔸㈠㈱㐠㠶㈠㐱㐠㘲㈠㘰㌠㠷ㄠ㔹㌠㌳ㄠ㌹㈠㘹㈠㄰㈠㠷㈠㜳㈠㐶㈠㐷㈠㐶㈠㔷㈠㌶㈠㔵㈠㐵㈠㠰㈠㤴ㄠ㔲㈠㤴㐠‶㐲‹㌱㈠㘴〠㈠㘴〠㈠㘴〠㈠㜴〠㈠㠴〠㈠㠴〠㈠㜴㠠㈠㔴ㄠ‶㐲‵㤱㈠㔴ㄠ‹㐲‵㠱㈠㜴ㄠ‶㐲‹ㄱ㈠〵ㄠ‰㔲‰〱
The BufferedWriter is not making an error and the code is correct except for
the redundancy of using
this.saveFile.delete();
try{this.saveFile.createNewFile();}
catch (IOException e ){System.out.println("File creation error");}
and
new FileWriter
The error in reading the data occurs when the file is opened. The depending on what program opens the data different results are displayed because of the way the software reads the data. Notepad was displaying symbols because it interpreted the numbers as ASCII. The console did not try to interpret the data and just displayed what was written to it. Using a program that does not try to interpret the numbers in the file will allow the data to be viewed correctly.
Since you did not provide and example of what data you write into the stream, you are probably experiencing the bush hid the facts phenomenon.

Android build error: ro.build.fingerprint cannot exceed 91 bytes

I'm building an android rom from the android source code but after about 5 minutes it gives this error.
error: ro.build.fingerprint cannot exceed 91 bytes: Android/mini_emulator_x86/mini-emulator-x86:5.0.555/AOSP/username02280306:userdebug/test-keys (97)
make: *** [out/target/product/mini-emulator-x86/system/build.prop] Error 1
make: *** Deleting file `out/target/product/mini-emulator-x86/system/build.prop'
make: *** Waiting for unfinished jobs....
How do I increase the ro.build.fingerprint size limit?
Plus I'm building on a Mac.
Edit build/tools/post_process_props.py. Change lines as follows:
PROP_NAME_MAX = 31
# PROP_VALUE_MAX = 91
PROP_VALUE_MAX = 128
Edit bionic/libc/include/sys/system_properties.h. Change lines as follows:
#define PROP_NAME_MAX 32
// #define PROP_VALUE_MAX 92
#define PROP_VALUE_MAX 128
Do
make clean
make
You can also run the second make command in parallel using syntax such as
make -j8
Alternatively, you can specify the build fingerprint string as command line argument to make using:
make -j5 BUILD_FINGERPRINT="....."
This will allow you to stay within the 91 byte limit.

ZipException thrown when using jogl in eclipse

This is Eclipse project build path:
files in project:
rob#work:~/git/thegame$ ll lib/linux32/
total 708
drwxr-xr-x 2 rob rob 4096 Mar 22 02:37 ./
drwxr-xr-x 4 rob rob 4096 Mar 22 02:23 ../
-rw-r--r-- 1 rob rob 8704 Mar 10 14:00 libgluegen-rt.so
-rw-r--r-- 1 rob rob 666380 Mar 11 03:22 libjogl_desktop.so
-rw-r--r-- 1 rob rob 5944 Mar 11 03:22 libnativewindow_awt.so
-rw-r--r-- 1 rob rob 26604 Mar 11 03:22 libnativewindow_x11.so
rob#work:~/git/thegame$ ll jar/
total 3308
drwxr-xr-x 3 rob rob 4096 Mar 22 02:28 ./
drwxr-xr-x 8 rob rob 4096 Mar 22 02:22 ../
-rw-r--r-- 1 rob rob 289171 Mar 10 14:00 gluegen-rt.jar
drwxr-xr-x 4 rob rob 4096 Mar 22 02:28 javadocs/
-rw-r--r-- 1 rob rob 3082066 Mar 11 03:23 jogl-all.jar
Error when trying to execute application:
Catched ZipException: error in opening zip file, while addNativeJarLibsImpl(classFromJavaJar class com.jogamp.common.os.Platform, classJarURI jar:file:/home/rob/git/thegame/jar/gluegen-rt.jar!/com/jogamp/common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-linux-i586.jar): [ file:/home/rob/git/thegame/jar/gluegen-rt.jar -> file:/home/rob/git/thegame/jar/ ] + gluegen-rt-natives-linux-i586.jar -> slim: jar:file:/home/rob/git/thegame/jar/gluegen-rt-natives-linux-i586.jar!/
Catched ZipException: error in opening zip file, while addNativeJarLibsImpl(classFromJavaJar class jogamp.nativewindow.NWJNILibLoader, classJarURI jar:file:/home/rob/git/thegame/jar/jogl-all.jar!/jogamp/nativewindow/NWJNILibLoader.class, nativeJarBaseName jogl-all-natives-linux-i586.jar): [ file:/home/rob/git/thegame/jar/jogl-all.jar -> file:/home/rob/git/thegame/jar/ ] + jogl-all-natives-linux-i586.jar -> slim: jar:file:/home/rob/git/thegame/jar/jogl-all-natives-linux-i586.jar!/
Catched IOException: TempJarCache: addNativeLibs: jar:file:/home/rob/git/thegame/jar/jogl-all-natives-linux-i586.jar!/, previous load attempt failed, while addNativeJarLibsImpl(classFromJavaJar class jogamp.nativewindow.NWJNILibLoader, classJarURI jar:file:/home/rob/git/thegame/jar/jogl-all.jar!/jogamp/nativewindow/NWJNILibLoader.class, nativeJarBaseName jogl-all-natives-linux-i586.jar): [ file:/home/rob/git/thegame/jar/jogl-all.jar -> file:/home/rob/git/thegame/jar/ ] + jogl-all-natives-linux-i586.jar -> slim: jar:file:/home/rob/git/thegame/jar/jogl-all-natives-linux-i586.jar!/
Catched IOException: TempJarCache: addNativeLibs: jar:file:/home/rob/git/thegame/jar/jogl-all-natives-linux-i586.jar!/, previous load attempt failed, while addNativeJarLibsImpl(classFromJavaJar class jogamp.nativewindow.NWJNILibLoader, classJarURI jar:file:/home/rob/git/thegame/jar/jogl-all.jar!/jogamp/nativewindow/NWJNILibLoader.class, nativeJarBaseName jogl-all-natives-linux-i586.jar): [ file:/home/rob/git/thegame/jar/jogl-all.jar -> file:/home/rob/git/thegame/jar/ ] + jogl-all-natives-linux-i586.jar -> slim: jar:file:/home/rob/git/thegame/jar/jogl-all-natives-linux-i586.jar!/
Main.java
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;
public class Main
{
public static void main(String[] args)
{
// setup OpenGL Version 2
GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities capabilities = new GLCapabilities(profile);
// The canvas is the widget that's drawn in the JFrame
GLCanvas glcanvas = new GLCanvas(capabilities);
glcanvas.addGLEventListener(new Renderer());
glcanvas.setSize( 300, 300 );
JFrame frame = new JFrame( "Hello World" );
frame.getContentPane().add( glcanvas);
// shutdown the program on windows close event
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
});
frame.setSize( frame.getContentPane().getPreferredSize() );
frame.setVisible( true );
}
}
When you download the JARs directly, some web browsers might wrap it into a ZIP file for "security" reasons. Rather download the 7z archive here and take the JARs it contains. You should follow these detailed instructions, it should work in Eclipse.
I remind you that the separated native libraries are no longer required in JOGL 2, rather use the JARs containing the native libraries, it is a lot less error prone, just put them into the same directory than the Java libraries relying on them (jogl-all.jar and gluegen-rt.jar).

java profile tool without gui

Is there a java profile tool that works without a GUI in Linux, just like top? I don't have the permission to use tools like jprofile and jvisualvm to work in remote model.
Try this: http://java.sun.com/developer/technicalArticles/Programming/HPROF.html You can query heap and cpu details.
You can use HPROF.
Command used: javac -J-agentlib:hprof=cpu=samples Hello.java
CPU SAMPLES BEGIN (total = 126) Fri Oct 22 12:12:14 2004
rank self accum count trace method
1 53.17% 53.17% 67 300027 java.util.zip.ZipFile.getEntry
2 17.46% 70.63% 22 300135 java.util.zip.ZipFile.getNextEntry
3 5.56% 76.19% 7 300111 java.lang.ClassLoader.defineClass2
4 3.97% 80.16% 5 300140 java.io.UnixFileSystem.list
5 2.38% 82.54% 3 300149 java.lang.Shutdown.halt0
6 1.59% 84.13% 2 300136 java.util.zip.ZipEntry.initFields
7 1.59% 85.71% 2 300138 java.lang.String.substring
8 1.59% 87.30% 2 300026 java.util.zip.ZipFile.open
9 0.79% 88.10% 1 300118 com.sun.tools.javac.code.Type$ErrorType.<init>
10 0.79% 88.89% 1 300134 java.util.zip.ZipFile.ensureOpen

Java Swing: A list of all UIDefaults properties

Question: Where can I get a list of all UIDefaults properties that exist in Swing?
I know of the possibility to write a small snippet of code that just extracts and displays them but I would like to know whether the list I get that way is really complete.
When I do so, I get 636 properties for the Metal L&F, 613 for Windows L&F and 550 for the Motif one. Another source on the net puts a list of 795 entries although it has some incorrect additional entries. But perhaps even the metal l&f does not set all it actually could.
I have difficulties to believe there really doesn't exist an official list of possible properties from sun.
Not all properties come from Sun. For example, Mac OS lists 654 properties + 51 specific to apple.laf.AquaLookAndFeel. Here's some code if others want to submit results:
import javax.swing.UIDefaults;
import javax.swing.UIManager;
public class CountUIDefaults {
public static void main(String[] args) throws Exception {
System.out.println(System.getProperty("os.name")
+ " " + System.getProperty("os.version")
+ " " + System.getProperty("java.version"));
UIManager.LookAndFeelInfo[] lfa =
UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lf : lfa) {
UIManager.setLookAndFeel(lf.getClassName());
UIDefaults uid = UIManager.getLookAndFeelDefaults();
System.out.println("***"
+ " " + lf.getName()
+ " " + lf.getClassName()
+ " " + uid.size() + " entries");
}
}
}
Mac OS X 10.5.8 1.6.0_17
*** Metal javax.swing.plaf.metal.MetalLookAndFeel 636 entries
*** Nimbus com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel 1052 entries
*** CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel 550 entries
*** Mac OS X com.apple.laf.AquaLookAndFeel 705 entries
Ah, well, I should have thought about that one more intensively.
Of course the list of "valid" properties is directly dependent on the used l&f and what you want to do with it:
Write an own l&f
In this case, the "official list" is the list of properties you get from the l&f you inherit. In case of MetalLookAndFeel, it's the 636 entries you can retrieve, I haven't tried the numbers for the more common BasicLookAndFeel and SynthLookAndFeel - I guess they can be checked by putting a more or less empty Subclass of those and running the code presented above.
Modify an existing l&f
In this case running the code for the l&f used yields everything that can be modified.
So in the end, the solution is that there cannot be a thing like an "official overall list" as such a one can only be put based on some specific l&f, in which case the code above will yield what one wants to know.
Linux 2.6.31-19-generic 1.6.0_0
*** Metal javax.swing.plaf.metal.MetalLookAndFeel 642 entries
*** CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel 556 entries
*** GTK+ com.sun.java.swing.plaf.gtk.GTKLookAndFeel 566 entries

Categories

Resources