java-7

How to invoke a MethodHandle with varargs

↘锁芯ラ 提交于 2019-12-10 14:44:12
问题 I'm trying to replace a reflective invocation with a MethodHandle, but varargs seem to be impossible to deal with. My reflective invoker currently looks like this: public class Invoker { private final Method delegate; public Invoker(Method delegate) { this.delegate = delegate; } public Object execute(Object target, Object[] args) { return delegate.invoke(target, args); } } My current attempt at rewriting it looks like this (the interface the Invoker exposes has to stay the same): public class

Websphere 8.0 and Java 1.7

帅比萌擦擦* 提交于 2019-12-10 14:20:09
问题 we're currently using Websphere 8.0.0.7 which runs with Java 1.6. Unfortunately, some of the portlets we would like to integrate into the portal need Java 1.7 to run. Is there any (simple) way to use Java 1.7 under Websphere 8.0.0.7? I found a lot of answers for Websphere 8.5, but especially not for 8.0. Is the use of 1.7 even possible? Thanks a lot for your effort! Philipp 回答1: WAS 8.0 will not support JAVA 7 (1.7). http://publib.boulder.ibm.com/infocenter/prodguid/v1r0/clarity-reports

Error in URL.getFile()

最后都变了- 提交于 2019-12-10 12:55:15
问题 I am trying to open a file from URL. Object of URL is created with getResource() method of ClassLoader. Output URL returned from getResource() method is = file:/C:/users/ After using URL.getFile() method which returns String as " /C:/users/ " it removes " file: " only not the " / " This / gives me a error in opening a file using new FileInputStream. Error : FileNotFoundException " / " in the starting of the filename causes the same problem in getting the path object. Here , value of directory

Files.createDirectory() : FileAlreadyExistsException

折月煮酒 提交于 2019-12-10 12:42:13
问题 I have a seemingly strange issue using Java 7's Files class. I want to make sure my directory and files exist before I start writing to avoid a FileNotFoundException , and according to the Javadocs, createDirectory checks for "the existence of the file and the creation of the directory if it does not exist" So if it checks first, why do I have a problem with the following code when the directory already exists? private void writeFile() throws IOException { // Make sure parent directory and

Are there known discrepencies between Apache FileUtils.isSymlink and Java7's Files.isSymbolicLink()?

天大地大妈咪最大 提交于 2019-12-10 10:25:46
问题 While debugging on my Windows 7 64 bit machine, I noticed that there is a symlink folder, that FileUtils.isSymlink() returns false for. Java7's Files.isSymbolicLink() works correctly. Is this known? Should i report a bug? 回答1: I believe this is a bug. Reported issue. 回答2: Its not a bug. FileUtils.isSymlink() is not supported in Windows. It always returns false for windows and its mentioned in the javadoc. Note: the current implementation always returns false if the system is detected as

My way to get X and Y index of buttons inside GridLayout

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 10:16:07
问题 This is related to How to get X and Y index of element inside GridLayout? post and its answers. For whatever reason none of them suggested to extend JButton to include its position in the grid and in associated array of buttons. I have made the following illustration that simply displays button's coordinates when it's clicked. Extended JButton : package buttons_array; import javax.swing.*; @SuppressWarnings("serial") public class ButtonWithCoordinates extends JButton { int coordX; int coordY;

JDK-7 SwingWorker deadlocks?

爱⌒轻易说出口 提交于 2019-12-10 09:27:53
问题 I have a small image processing application which does multiple things at once using SwingWorker. However, if I run the following code (oversimplified excerpt), it just hangs on JDK 7 b70 (windows) but works in 6u16. It starts a new worker within another worker and waits for its result (the real app runs multiple sub-workers and waits for all this way). Did I use some wrong patterns here (as mostly there is 3-5 workers in the swingworker-pool, which has limit of 10 I think)? import javax

Tweaking the behavior of the default file system in Java 7

时光毁灭记忆、已成空白 提交于 2019-12-10 08:49:27
问题 Java 7 introduces a great API for writing custom file systems. Consider a use case where I don't want to implement a new file system, I just want to tweak the behavior of the existing one. For example, flip every bit that is written/read from it. It seems to me that the current jdk just does not have the appropriate facilities for this. AbstractFileSystemProvider, the provider that WindowsFileSystemProvider extends is package-private so I can't reuse it. I didn't even find the concrete

Java: Thread producer consumer what is the most efficient way to wait for data to be produced

烈酒焚心 提交于 2019-12-10 04:33:05
问题 When using BlockingQueue to consume data that is produced what is the most efficient method for waiting for the data to appear? Scenario: Step 1) The data list will be a data store where timestamps are added to. These timestamps are required to be ordered by closest to current time priority. This list may be empty. A thread will be inserting the timestamps into it. Produce Step 2) I want to consume the data in here in another thread that will take the timestamps from data and check if they

Why will there be no native properties in Java 7?

允我心安 提交于 2019-12-10 01:14:16
问题 Is there any rational reason, why native properties will not be part of Java 7? 回答1: Doing properties "right" in Java will not be easy. Rémi Forax's work especially has been valuable in figuring out what this might look like, and uncovering a lot of the "gotchas" that will have to be dealt with. Meanwhile, Java 7 has already taken too long. The closures debate was a huge, controversial distraction that wasted a lot of mind-power that could have been used to develop features (like properties)