diff options
author | Matthias Klose <doko@gcc.gnu.org> | 2008-06-28 13:29:13 +0000 |
---|---|---|
committer | Matthias Klose <doko@gcc.gnu.org> | 2008-06-28 13:29:13 +0000 |
commit | e0441a5bfb29083a532307ba2b1fd6d6d13944ba (patch) | |
tree | 602cd7aa7c947386134690d8e0f6b53abcdeacb9 /libjava/classpath/examples | |
parent | 15c151967dd1cde61b79d26374f608f63a29d411 (diff) | |
download | gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.zip gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.gz gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.bz2 |
Import GNU Classpath (classpath-0_97_2-release).
libjava/
2008-06-28 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (classpath-0_97_2-release).
* Regenerate class and header files.
* Regenerate auto* files.
* gcj/javaprims.h: Define jobjectRefType.
* jni.cc (_Jv_JNI_GetObjectRefType): New (stub only).
(_Jv_JNIFunctions): Initialize GetObjectRefType.
* gnu/classpath/jdwp/VMVirtualMachine.java,
java/security/VMSecureRandom.java: Merge from classpath.
* HACKING: Fix typo.
* ChangeLog-2007: New file.
* configure.ac: Set JAVAC, pass --disable-regen-headers to classpath.
libjava/classpath/
2008-06-28 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_javac.m4: Disable check for JAVAC, when
not configured with --enable-java-maintainer-mode.
* aclocal.m4, configure: Regenerate.
* native/jni/gstreamer-peer/Makefile.am: Do not link with
libclasspathnative.
* native/jni/gstreamer-peer/Makefile.in: Regenerate.
* tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting
JCOMPILER, drop flags not understood by gcj.
From-SVN: r137223
Diffstat (limited to 'libjava/classpath/examples')
14 files changed, 275 insertions, 91 deletions
diff --git a/libjava/classpath/examples/Makefile.am b/libjava/classpath/examples/Makefile.am index 8d619e1..56b3c45 100644 --- a/libjava/classpath/examples/Makefile.am +++ b/libjava/classpath/examples/Makefile.am @@ -1,24 +1,7 @@ ## Input file for automake to generate the Makefile.in used by configure -GLIBJ_CLASSPATH='$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip':'$(top_builddir)/tools/tools.zip' - -# Setup the compiler to use the GNU Classpath library we just build -#if FOUND_GCJ -#JCOMPILER = $(GCJ) --bootclasspath '$(top_builddir)/lib' --classpath . -C -#else -#if FOUND_JIKES -#JCOMPILER = $(JIKES) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(top_builddir)/lib:. -#else -if FOUND_ECJ -JCOMPILER = $(ECJ) -1.5 -encoding UTF-8 -warn:-deprecation,serial,typeHiding,unchecked,unused,varargsCast -bootclasspath $(GLIBJ_CLASSPATH) -classpath . -else -if FOUND_JAVAC -JCOMPILER = $(JAVAC) -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath . -else -error dunno how to setup the JCOMPILER and compile -#endif -#endif -endif -endif +GLIBJ_CLASSPATH='$(top_builddir)/lib/glibj.zip' + +JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath '$(top_builddir)/tools/tools.zip' # All our example java source files EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*/*.java diff --git a/libjava/classpath/examples/Makefile.in b/libjava/classpath/examples/Makefile.in index e5e0a0e..fa7082c 100644 --- a/libjava/classpath/examples/Makefile.in +++ b/libjava/classpath/examples/Makefile.in @@ -51,6 +51,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \ $(top_srcdir)/../../ltoptions.m4 \ $(top_srcdir)/../../ltsugar.m4 \ $(top_srcdir)/../../ltversion.m4 \ + $(top_srcdir)/m4/ac_prog_javac.m4 \ + $(top_srcdir)/m4/ac_prog_javac_works.m4 \ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \ $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/ax_create_stdint_h.m4 \ @@ -140,7 +142,6 @@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ -ECJ = @ECJ@ ECJ_JAR = @ECJ_JAR@ EGREP = @EGREP@ ENABLE_LOCAL_SOCKETS_FALSE = @ENABLE_LOCAL_SOCKETS_FALSE@ @@ -152,19 +153,8 @@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ FASTJAR = @FASTJAR@ FGREP = @FGREP@ FIND = @FIND@ -FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@ -FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@ -FOUND_GCJ_FALSE = @FOUND_GCJ_FALSE@ -FOUND_GCJ_TRUE = @FOUND_GCJ_TRUE@ -FOUND_JAVAC_FALSE = @FOUND_JAVAC_FALSE@ -FOUND_JAVAC_TRUE = @FOUND_JAVAC_TRUE@ -FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@ -FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@ -FOUND_KJC_FALSE = @FOUND_KJC_FALSE@ -FOUND_KJC_TRUE = @FOUND_KJC_TRUE@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@ FREETYPE2_LIBS = @FREETYPE2_LIBS@ -GCJ = @GCJ@ GCONF_CFLAGS = @GCONF_CFLAGS@ GCONF_LIBS = @GCONF_LIBS@ GDK_CFLAGS = @GDK_CFLAGS@ @@ -196,15 +186,12 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ JAVAC = @JAVAC@ +JAVAC_MEM_OPT = @JAVAC_MEM_OPT@ JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@ JAVA_MAINTAINER_MODE_FALSE = @JAVA_MAINTAINER_MODE_FALSE@ JAVA_MAINTAINER_MODE_TRUE = @JAVA_MAINTAINER_MODE_TRUE@ JAY = @JAY@ JAY_SKELETON = @JAY_SKELETON@ -JIKES = @JIKES@ -JIKESENCODING = @JIKESENCODING@ -JIKESWARNINGS = @JIKESWARNINGS@ -KJC = @KJC@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDEBUG = @LIBDEBUG@ @@ -252,10 +239,8 @@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ STRIP = @STRIP@ -USER_CLASSLIB = @USER_CLASSLIB@ +TOOLSDIR = @TOOLSDIR@ USER_JAVAH = @USER_JAVAH@ -USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@ -USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@ USE_ESCHER_FALSE = @USE_ESCHER_FALSE@ USE_ESCHER_TRUE = @USE_ESCHER_TRUE@ USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@ @@ -327,19 +312,8 @@ target_os = @target_os@ target_vendor = @target_vendor@ toolexeclibdir = @toolexeclibdir@ vm_classes = @vm_classes@ -GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip':'$(top_builddir)/tools/tools.zip' -@FOUND_ECJ_FALSE@@FOUND_JAVAC_TRUE@JCOMPILER = $(JAVAC) -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath . - -# Setup the compiler to use the GNU Classpath library we just build -#if FOUND_GCJ -#JCOMPILER = $(GCJ) --bootclasspath '$(top_builddir)/lib' --classpath . -C -#else -#if FOUND_JIKES -#JCOMPILER = $(JIKES) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(top_builddir)/lib:. -#else -@FOUND_ECJ_TRUE@JCOMPILER = $(ECJ) -1.5 -encoding UTF-8 -warn:-deprecation,serial,typeHiding,unchecked,unused,varargsCast -bootclasspath $(GLIBJ_CLASSPATH) -classpath . -#endif -#endif +GLIBJ_CLASSPATH = '$(top_builddir)/lib/glibj.zip' +JCOMPILER = $(JAVAC) $(JAVACFLAGS) -source 1.5 -target 1.5 -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath '$(top_builddir)/tools/tools.zip' # All our example java source files EXAMPLE_JAVA_FILES = $(srcdir)/gnu/classpath/examples/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*.java $(srcdir)/gnu/classpath/examples/*/*/*/*.java @@ -568,7 +542,6 @@ uninstall-am: uninstall-exampleDATA uninstall-info-am uninstall-local uninstall uninstall-am uninstall-exampleDATA uninstall-info-am \ uninstall-local -@FOUND_ECJ_FALSE@@FOUND_JAVAC_FALSE@error dunno how to setup the JCOMPILER and compile # Make sure all sources and icons are also installed so users can use them. # (Be careful to strip off the srcdir part of the path when installing.) diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java index 652ee53..155ad17 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java @@ -40,7 +40,6 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication; import gnu.CORBA.OrbRestricted; -import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java index 2ac03a8..83f422c 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java @@ -39,7 +39,6 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication; import gnu.CORBA.OrbRestricted; -import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TCKind; import org.omg.CORBA.TypeCode; diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java index ccf792d..eac1c9a 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java @@ -42,7 +42,6 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication; import gnu.CORBA.OrbRestricted; import org.omg.CORBA.Any; -import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; diff --git a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java index 6ad13a9..adf4d25 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java +++ b/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java @@ -41,7 +41,6 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication; import gnu.CORBA.OrbRestricted; import org.omg.CORBA.Any; -import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TCKind; import org.omg.CORBA.TypeCode; diff --git a/libjava/classpath/examples/gnu/classpath/examples/awt/AnimationApplet.java b/libjava/classpath/examples/gnu/classpath/examples/awt/AnimationApplet.java index 9d3b7ce..aea8cd4 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/awt/AnimationApplet.java +++ b/libjava/classpath/examples/gnu/classpath/examples/awt/AnimationApplet.java @@ -21,7 +21,6 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA package gnu.classpath.examples.awt; import java.awt.*; -import java.awt.event.*; import java.applet.*; diff --git a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java index 6d35918..a0b51f0 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java +++ b/libjava/classpath/examples/gnu/classpath/examples/java2d/J2dBenchmark.java @@ -601,7 +601,7 @@ public class J2dBenchmark void runTestSet(Graphics2D g, Dimension size) { // Any user-specified options (ie set transforms, rendering hints) - prepareGraphics((Graphics2D) g); + prepareGraphics(g); if ((awtTests & J2DTEST_ARC) != 0) { diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java index ad82345..381dca4 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestBeans.java @@ -22,34 +22,19 @@ package gnu.classpath.examples.management; import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.Set; -import javax.management.DynamicMBean; +import javax.management.MBeanServer; +import javax.management.ObjectName; public class TestBeans { public static void main(String[] args) throws Exception { - List beans = new ArrayList(); - /* FIXME: When there's a server, this will be easier... :) */ - beans.add(ManagementFactory.getOperatingSystemMXBean()); - beans.add(ManagementFactory.getRuntimeMXBean()); - beans.add(ManagementFactory.getThreadMXBean()); - beans.add(ManagementFactory.getCompilationMXBean()); - beans.add(ManagementFactory.getClassLoadingMXBean()); - beans.add(ManagementFactory.getMemoryMXBean()); - beans.addAll(ManagementFactory.getMemoryPoolMXBeans()); - beans.addAll(ManagementFactory.getMemoryManagerMXBeans()); - beans.addAll(ManagementFactory.getGarbageCollectorMXBeans()); - Iterator it = beans.iterator(); - while (it.hasNext()) - { - DynamicMBean bean = (DynamicMBean) it.next(); - if (bean != null) - System.out.println(bean.getMBeanInfo()); - } + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + Set<ObjectName> names = server.queryNames(null, null); + for (ObjectName name : names) + System.out.println(server.getMBeanInfo(name)); } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java index 113a4f2..b4e8d98 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestClassLoading.java @@ -23,10 +23,18 @@ package gnu.classpath.examples.management; import java.lang.management.ClassLoadingMXBean; import java.lang.management.ManagementFactory; +import static java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME; + +import javax.management.Attribute; +import javax.management.MBeanServer; +import javax.management.ObjectName; + public class TestClassLoading { public static void main(String[] args) + throws Exception { + System.out.println("Testing locally..."); ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean(); System.out.println("Bean: " + bean); System.out.println("Loaded classes: " + bean.getLoadedClassCount()); @@ -37,5 +45,33 @@ public class TestClassLoading System.out.println("Changing verbose setting..."); bean.setVerbose(!verbosity); System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no")); + System.out.println("Testing via the server..."); + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + ObjectName classBean = new ObjectName(CLASS_LOADING_MXBEAN_NAME); + System.out.println("Bean: " + classBean); + System.out.println("Loaded classes: " + server.getAttribute(classBean, "LoadedClassCount")); + System.out.println("Unloaded classes: " + server.getAttribute(classBean, + "UnloadedClassCount")); + System.out.println("Total loaded classes: " + server.getAttribute(classBean, + "TotalLoadedClassCount")); + verbosity = (Boolean) server.getAttribute(classBean, "Verbose"); + System.out.println("Verbose class output: " + (verbosity ? "yes" : "no")); + System.out.println("Changing verbose setting..."); + server.setAttribute(classBean, new Attribute("Verbose", !verbosity)); + System.out.println("Verbose class output: " + ((Boolean) + server.getAttribute(classBean, "Verbose") ? + "yes" : "no")); + System.out.println("Testing via the proxy..."); + bean = ManagementFactory.newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME, + ClassLoadingMXBean.class); + System.out.println("Bean: " + bean); + System.out.println("Loaded classes: " + bean.getLoadedClassCount()); + System.out.println("Unloaded classes: " + bean.getUnloadedClassCount()); + System.out.println("Total loaded classes: " + bean.getTotalLoadedClassCount()); + verbosity = bean.isVerbose(); + System.out.println("Verbose class output: " + (verbosity ? "yes" : "no")); + System.out.println("Changing verbose setting..."); + bean.setVerbose(!verbosity); + System.out.println("Verbose class output: " + (bean.isVerbose() ? "yes" : "no")); } } diff --git a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java index 2476ed7..1836c30 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java +++ b/libjava/classpath/examples/gnu/classpath/examples/management/TestMemoryPool.java @@ -22,8 +22,6 @@ package gnu.classpath.examples.management; import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; -import java.lang.management.MemoryUsage; - import java.util.Arrays; import java.util.Iterator; diff --git a/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java b/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java new file mode 100644 index 0000000..5c44c9a --- /dev/null +++ b/libjava/classpath/examples/gnu/classpath/examples/sound/AudioPlayerSample.java @@ -0,0 +1,222 @@ +/* AudioPlayerSample.java -- Simple Java Audio Player + Copyright (C) 2007 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ +package gnu.classpath.examples.sound; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.SourceDataLine; +import javax.sound.sampled.UnsupportedAudioFileException; + +/** + * A simple demo to show the use of the Java Sound API. + * It plays the given file (up to the end, so don't pass the 26 minutes long + * Pink Floyd's Echoes unless you really want!!). + * + * See: http://jsresources.org/examples/SimpleAudioPlayer.java.html + * + * @author Mario Torre <neugens@limasoftware.net> + */ +public class AudioPlayerSample +{ + private static final int EXTERNAL_BUFFER_SIZE = 128000; + + /** + * @param args + */ + public static void main(String[] args) + { + if (args.length < 1) + { + System.out.println("Radio Classpath -: Usage: " + + "AudioPlayerSample [file]"); + return; + } + + String file = args[0]; + + System.out.println("Welcome to Radio Classpath, only great music for you!"); + System.out.println("Today's DJ Tap The WaterDroplet"); + + // now create the AudioInputStream + AudioInputStream audioInputStream = null; + try + { + audioInputStream = AudioSystem.getAudioInputStream(new File(file)); + } + catch (UnsupportedAudioFileException e) + { + // This happen when the subsystem is unable to parse the kind of + // audio file we are submitting + // See the README for supported audio file types under Classpath + // for the version you are using. + e.printStackTrace(); + return; + } + catch (IOException e) + { + e.printStackTrace(); + return; + } + + // get informations about the kind of file we are about to play + AudioFormat audioFormat = audioInputStream.getFormat(); + + System.out.println("Playing file: " + file); + System.out.println("format: " + audioFormat.toString()); + + System.out.print("Additional properties: "); + + // now, we try to get all the properties we have in this AudioFormat + // and display them + Map<String, Object> properties = audioFormat.properties(); + if (properties.size() < 0) + { + System.out.println("none"); + } + else + { + System.out.println("found #" + properties.size() + " properties"); + for (String key : properties.keySet()) + { + System.out.println(key + ": " + properties.get(key)); + } + } + + // let's setup things for playing + // first, we require a Line. As we are doing playing, we will ask for a + // SourceDataLine + SourceDataLine line = null; + + // To get the source line, we first need to build an Info object + // this is done in one line: + DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); + + System.out.println("searching line..."); + + // usually, if a backend can parse a file type, it can also + // create a line to handle it, but that's not guaranteed + // so we need to take care and to handle a possible + // LineUnavailableException + try + { + line = (SourceDataLine) AudioSystem.getLine(info); + + System.out.println("line found, opening..."); + + // once created, a line must be opened to let data flow + // though it. + line.open(audioFormat); + } + catch (LineUnavailableException e) + { + // in a real application you should signal that in a kindly way to + // your users + e.printStackTrace(); + return; + } + catch (Exception e) + { + e.printStackTrace(); + return; + } + + // an open line pass data to the backend only when it is in + // a state called "started" ("playing" or "play" in some other + // framework) + System.out.print("starting line... "); + + line.start(); + System.out.println("done"); + + // now we can start reading data from the AudioStream and writing + // data to the pipeline. The Java Sound API is rather low level + // so let you pass up to one byte of data at a time + // (with some constraints, refer to the API documentation to know more) + // We will do some buffering. You may want to check the frame size + // to allow a better buffering, also. + + System.out.println("now playing..."); + + int nBytesRead = 0; + byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; + while (nBytesRead != - 1) + { + try + { + nBytesRead = audioInputStream.read(abData, 0, abData.length); + } + catch (IOException e) + { + e.printStackTrace(); + } + + if (nBytesRead >= 0) + { + // this method returns the number of bytes actuall written + // to the line. You may want to use this number to check + // for events, display the current position (give also a + // look to the API for other ways of doing that) etc.. + line.write(abData, 0, nBytesRead); + } + } + + System.out.print("stream finished, draining line... "); + + // call this method to ensure that all the data in the internal buffer + // reach the audio backend, otherwise your application will + // cut the last frames of audio data (and users will not enjoy the last + // seconds of their precious music) + line.drain(); + + // Once done, we can close the line. Note that a line, once closed + // may not be reopened (depends on the backend, in some cases a "reopen", + // if allowed, really opens a new line, reallocating all the resources) + + System.out.println("line drained, now exiting"); + line.close(); + + System.out.println("We hope you enjoyed Radio Classpath!"); + } + +} diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java index 28dce1c..b338e43 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java @@ -44,7 +44,6 @@ import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.DocumentFilter; -import javax.swing.text.TextAction; /** * A demonstration of the <code>javax.swing.text.DocumentFilter</code> class. diff --git a/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java b/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java index d4a97b3..9f8e3e7 100644 --- a/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java +++ b/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java @@ -41,25 +41,18 @@ package gnu.classpath.examples.swing; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.Rectangle; -import java.text.DateFormat; -import java.util.Date; - import javax.swing.AbstractCellEditor; import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; -import javax.swing.DefaultListCellRenderer; import javax.swing.Icon; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; -import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.JSlider; import javax.swing.JTable; -import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.plaf.metal.MetalIconFactory; |