Description
swing JTextField ctrl+v Can't paste
Exception in thread "AWT-EventQueue-0" java.lang.InternalError: Default flavor mapping not found at java.awt.datatransfer.SystemFlavorMap.initSystemFlavorMap(SystemFlavorMap.java:213) at java.awt.datatransfer.SystemFlavorMap.getTextTypeToNative(SystemFlavorMap.java:158) at java.awt.datatransfer.SystemFlavorMap.getNativesForFlavor(SystemFlavorMap.java:535) at sun.awt.datatransfer.DataTransferer.getFormatsForFlavors(DataTransferer.java:357) at sun.awt.windows.WDataTransferer.getFormatsForFlavors(WDataTransferer.java:174) at sun.awt.datatransfer.DataTransferer.getFormatsForTransferable(DataTransferer.java:311) at sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:73) at sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:105) at javax.swing.TransferHandler.exportToClipboard(TransferHandler.java:787) at javax.swing.TransferHandler$TransferAction.actionPerformedImpl(TransferHandler.java:1750) at javax.swing.TransferHandler$TransferAction$1.run(TransferHandler.java:1712) at javax.swing.TransferHandler$TransferAction$1.run(TransferHandler.java:1710) at java.security.AccessController.executePrivileged(AccessController.java:169) at java.security.AccessController.doPrivileged(AccessController.java:91) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at javax.swing.TransferHandler$TransferAction$2.run(TransferHandler.java:1727) at javax.swing.TransferHandler$TransferAction$2.run(TransferHandler.java:1725) at java.security.AccessController.executePrivileged(AccessController.java:169) at java.security.AccessController.doPrivileged(AccessController.java:91) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at javax.swing.TransferHandler$TransferAction.actionPerformed(TransferHandler.java:1724) at javax.swing.text.JTextComponent.invokeAction(JTextComponent.java:1523) at javax.swing.text.JTextComponent.copy(JTextComponent.java:1484) at javax.swing.text.DefaultEditorKit$CopyAction.actionPerformed(DefaultEditorKit.java:1335) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1810) at javax.swing.JComponent.processKeyBinding(JComponent.java:2900) at javax.swing.JComponent.processKeyBindings(JComponent.java:2948) at javax.swing.JComponent.processKeyEvent(JComponent.java:2862) at java.awt.Component.processEvent(Component.java:6412) at java.awt.Container.processEvent(Container.java:2263) at java.awt.Component.dispatchEventImpl(Component.java:5011) at java.awt.Container.dispatchEventImpl(Container.java:2321) at java.awt.Component.dispatchEvent(Component.java:4843) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:870) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1139) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1009) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:835) at java.awt.Component.dispatchEventImpl(Component.java:4892) at java.awt.Container.dispatchEventImpl(Container.java:2321) at java.awt.Window.dispatchEventImpl(Window.java:2772) at java.awt.Component.dispatchEvent(Component.java:4843) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.awt.EventQueue$4.run(EventQueue.java:721) at java.awt.EventQueue$4.run(EventQueue.java:715) at java.security.AccessController.executePrivileged(AccessController.java:169) at java.security.AccessController.doPrivileged(AccessController.java:91) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.awt.EventQueue$5.run(EventQueue.java:745) at java.awt.EventQueue$5.run(EventQueue.java:743) at java.security.AccessController.executePrivileged(AccessController.java:169) at java.security.AccessController.doPrivileged(AccessController.java:91) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:705) at com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:143)
=====================
SystemFlavorMap line 213 :
private void initSystemFlavorMap() {
if (isMapInitialized) {
return;
}
isMapInitialized = true;
InputStream is = AccessController.doPrivileged(
(PrivilegedAction<InputStream>) () -> {
return SystemFlavorMap.class.getResourceAsStream(
"/sun/datatransfer/resources/flavormap.properties");
});
if (is == null) {
throw new InternalError("Default flavor mapping not found");
}
SystemFlavorMap.class.getResourceAsStream("/sun/datatransfer/resources/flavormap.properties")
Cause an exception to be thrown. How to solve it
Activity
iceman567 commentedon Nov 5, 2022
solve
oubidar-Abderrahim commentedon Nov 9, 2022
Hi, do you still face this issue? if yes, could you please share a small reproducer with steps to reach this issue? Thank you
iceman567 commentedon Nov 20, 2022
resource-config.json
add
includes: []
{ "pattern":"\\Qsun/datatransfer/resources/flavormap.properties\\E" }
==================
tips:
I suspect agentlib native-image-agent.exe has a bug. So that the resource sun/datatransfer/resources/flavormap.properties is not captured
我怀疑 agentlib native-image-agent.exe 有bug。以至于没有捕捉到该资源sun/datatransfer/resources/flavormap.properties
oubidar-Abderrahim commentedon Nov 29, 2022
Yes, this is a known issue. you need to manually register the sun/datatransfer/resources/flavormap.properties resource
It can be registered either by adding an entry to the existing resource-config.json file or via the command line by passing
-H:IncludeResources=sun/datatransfer/resources/flavormap.properties
to the image builder.