Duplicate :
|
FULL PRODUCT VERSION : java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b66) Java HotSpot(TM) Client VM (build 16.0-b06, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7600] A DESCRIPTION OF THE PROBLEM : The attached program displays the "Ne..." on the button instead of fully showing the "Next" label. This works with 1.6u14. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the attached program EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Button label shows "Next" http://karnokd.uw.hu/gl_problem_6.png ACTUAL - Button label is displayed as "Ne..." http://karnokd.uw.hu/gl_problem_7.png REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- package gui; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.GroupLayout.Alignment; public class RecursiveContinue extends JFrame { private static final long serialVersionUID = 7149607943058112216L; JLabel value; JButton next; volatile SwingWorker<Void, Void> worker; Lock lock = new ReentrantLock(); Condition cond = lock.newCondition(); boolean continueFlag; public RecursiveContinue() { super("Recursive Continue Example"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); value = new JLabel("Recursion depth: None"); next = new JButton("Next"); next.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doNextClick(); } }); Container c = getContentPane(); GroupLayout gl = new GroupLayout(c); c.setLayout(gl); gl.setAutoCreateContainerGaps(true); gl.setAutoCreateGaps(true); gl.setHorizontalGroup( gl.createSequentialGroup() .addComponent(value) .addComponent(next) ); gl.setVerticalGroup( gl.createParallelGroup(Alignment.BASELINE) .addComponent(value) .addComponent(next) ); pack(); setLocationRelativeTo(null); } void doNextClick() { if (worker == null) { worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { doRecursiveAction(0); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { value.setText("Recursive level: Done"); } }); worker = null; return null; } }; worker.execute(); } else { signal(); } } void signal() { lock.lock(); try { continueFlag = true; cond.signalAll(); } finally { lock.unlock(); } } void await() { lock.lock(); try { while (!continueFlag) { cond.await(); } continueFlag = false; } catch (InterruptedException e) { throw new RuntimeException(e); } finally { lock.unlock(); } } void doRecursiveAction(final int depth) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { value.setText("Recursive level: " + depth); } }); await(); if (depth < 10) { doRecursiveAction(depth + 1); } } /** * @param args */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new RecursiveContinue().setVisible(true); } }); } } ---------- END SOURCE ---------- Release Regression From : 6u14 The above release value was the last known release where this bug was not reproducible. Since then there has been a regression.