You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/06/11 07:15:37 UTC
svn commit: r546011 - in /harmony/enhanced/classlib/branches/java6/modules:
awt/ awt/src/main/java/common/java/awt/
awt/src/main/java/common/org/apache/harmony/awt/gl/
awt/src/main/java/common/org/apache/harmony/awt/gl/font/
awt/src/main/java/common/or...
Author: pyang
Date: Sun Jun 10 22:15:33 2007
New Revision: 546011
URL: http://svn.apache.org/viewvc?view=rev&rev=546011
Log:
Merge updates from classlib trunk@545915 since r545213
Added:
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/
- copied from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/
- copied from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/
- copied from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/AGL.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/AGL.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/EncodedValue.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Environment.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Environment.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Font.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Font.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Glyph.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Glyph.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Outline.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Outline.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/T1Font.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/T1Font.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/T1Glyph.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Glyph.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/T1Glyph.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Glyph.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TTCurve.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTCurve.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TTCurve.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTCurve.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TTFont.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTFont.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/TTFont.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTFont.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Tables.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Tables.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/Type1Structs.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Type1Structs.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/fljni.cpp
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/fljni.cpp
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/include/
- copied from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/include/fljni.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/fljni.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLFontManager.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLFontManager.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLFontPeer.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLFontPeer.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLGlyph.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLGlyph.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLPath.h
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLPath.h
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/unix/
- copied from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/unix/exports.txt
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/unix/makefile
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/windows/
- copied from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/windows/fl.def
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/fl.def
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/windows/fl.rc
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/fl.rc
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/windows/makefile
- copied unchanged from r545915, harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile
Modified:
harmony/enhanced/classlib/branches/java6/modules/awt/build.xml
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java
harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl
harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm
harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl
harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/unix/hysock.h
harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysock.c
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/build.xml?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/build.xml Sun Jun 10 22:15:33 2007
@@ -178,6 +178,16 @@
<exclude name="*${manifest.suffix}"/>
</fileset>
</copy>
+
+ <make dir="${hy.awt.src.main.native}/fontlib/${hy.os.family}" />
+ <!-- Copy the built shared libs over to the jre/bin dir -->
+ <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+ <fileset dir="${hy.awt.src.main.native}/fontlib">
+ <include name="*${shlib.suffix}*"/>
+ <include name="*${progdb.suffix}*" if="is.windows" />
+ <exclude name="*${manifest.suffix}"/>
+ </fileset>
+ </copy>
</target>
<target name="-build-native-unix" if="is.unix">
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java Sun Jun 10 22:15:33 2007
@@ -24,6 +24,7 @@
import java.awt.font.TransformAttribute;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import java.awt.peer.FontPeer;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -38,11 +39,12 @@
import java.util.Map;
import java.util.StringTokenizer;
-import java.awt.peer.FontPeer;
-
import org.apache.harmony.awt.gl.font.CommonGlyphVector;
+import org.apache.harmony.awt.gl.font.FontManager;
import org.apache.harmony.awt.gl.font.FontPeerImpl;
+import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
import org.apache.harmony.awt.internal.nls.Messages;
+import org.apache.harmony.luni.util.NotImplementedException;
import org.apache.harmony.misc.HashCode;
@@ -245,8 +247,14 @@
if (!Character.isValidCodePoint(i)) {
throw new IllegalArgumentException();
}
- //TODO implement true code point support
- return canDisplay((char)i);
+
+ if (!FontManager.IS_FONTLIB) {
+ //TODO implement true code point support
+ return canDisplay((char)i);
+ } else {
+ FontPeerImpl peer = (FontPeerImpl)this.getPeer();
+ return peer.canDisplay(peer.getUnicodeByIndex(i));
+ }
}
public int canDisplayUpTo(char[] text, int start, int limit) {
@@ -311,19 +319,25 @@
}
public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes) throws org.apache.harmony.luni.util.NotImplementedException {
- // TODO : to find out, how to operate with glyphcodes
- if (true) {
- throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
+ if (!FontManager.IS_FONTLIB) {
+ // TODO : to find out, how to operate with glyphcodes
+ throw new NotImplementedException();
}
- return null;
+
+ int length = glyphCodes.length;
+ char[] chars = new char[length];
+ FontPeerImpl peer = (FontPeerImpl) getPeer();
+
+ for (int i = 0; i < length; i ++) {
+ chars[i] = peer.getUnicodeByIndex(glyphCodes[i]);
+ }
+
+ return new CommonGlyphVector(chars, frc, this, 0);
}
public GlyphVector createGlyphVector(FontRenderContext frc, String str) {
-
return new CommonGlyphVector(str.toCharArray(), frc, this, 0);
-
-
}
/**
@@ -596,7 +610,7 @@
}
- public String getFontName() {
+ public String getFontName() {
FontPeerImpl peer = (FontPeerImpl)this.getPeer();
return peer.getFontName();
}
@@ -608,6 +622,7 @@
public LineMetrics getLineMetrics(char[] chars, int start, int end,
FontRenderContext frc) {
+
if (frc == null) {
// awt.00=FontRenderContext is null
throw new NullPointerException(Messages.getString("awt.00")); //$NON-NLS-1$
@@ -845,9 +860,14 @@
* @deprecated
*/
@Deprecated
- public FontPeer getPeer() {
+ public FontPeer getPeer() {
if (fontPeer == null){
- fontPeer = (FontPeerImpl)Toolkit.getDefaultToolkit().getGraphicsFactory().getFontPeer(this);
+ fontPeer = (FontPeerImpl) FontManager.getInstance().getFontPeer(
+ this.getName(),
+ this.getStyle(),
+ this.getSize()
+ );
+
}
return fontPeer;
}
@@ -936,11 +956,22 @@
public static Font createFont(int fontFormat, File fontFile) throws FontFormatException,
IOException {
- InputStream is = new FileInputStream(fontFile);
- try {
- return createFont(fontFormat, is);
- } finally {
- is.close();
+ if (fontFile == null) throw new NullPointerException();
+
+ if (FontManager.IS_FONTLIB) {
+ if (fontFormat != TRUETYPE_FONT && fontFormat != TYPE1_FONT) {
+ // awt.9A=Unsupported font format
+ throw new IllegalArgumentException ( Messages.getString("awt.9A") ); //$NON-NLS-1$
+ }
+
+ return ((FLFontManager)FontManager.getInstance()).embedFont(fontFile.getAbsolutePath(), fontFormat);
+ } else {
+ InputStream is = new FileInputStream(fontFile);
+ try {
+ return createFont(fontFormat, is);
+ } finally {
+ is.close();
+ }
}
}
@@ -952,13 +983,14 @@
int size = 8192; // memory page size, for the faster reading
byte buf[] = new byte[size];
- if (fontFormat != TRUETYPE_FONT) {
+ if (fontFormat != TRUETYPE_FONT && !FontManager.IS_FONTLIB) {
// awt.9A=Unsupported font format
throw new IllegalArgumentException ( Messages.getString("awt.9A") ); //$NON-NLS-1$
}
/* Get font file in system-specific directory */
- File fontFile = Toolkit.getDefaultToolkit().getGraphicsFactory().getFontManager().getTempFontFile();
+ File fontFile = FontManager.getInstance().getTempFontFile();
+// File fontFile = Toolkit.getDefaultToolkit().getGraphicsFactory().getFontManager().getTempFontFile();
buffStream = new BufferedInputStream ( fontStream );
@@ -975,8 +1007,12 @@
fOutStream.close();
Font font = null;
-
- font = Toolkit.getDefaultToolkit().getGraphicsFactory().embedFont(fontFile.getAbsolutePath());
+
+ if (FontManager.IS_FONTLIB) {
+ font = ((FLFontManager)FontManager.getInstance()).embedFont(fontFile.getAbsolutePath(), fontFormat);
+ } else {
+ font = Toolkit.getDefaultToolkit().getGraphicsFactory().embedFont(fontFile.getAbsolutePath());
+ }
if ( font == null ) {
// awt.9B=Can't create font - bad font data
throw new FontFormatException ( Messages.getString("awt.9B") ); //$NON-NLS-1$
@@ -985,4 +1021,5 @@
}
}
+
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java Sun Jun 10 22:15:33 2007
@@ -58,6 +58,8 @@
import java.util.Map;
import org.apache.harmony.awt.gl.Surface;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.fontlib.FLTextRenderer;
import org.apache.harmony.awt.gl.image.OffscreenImage;
import org.apache.harmony.awt.gl.render.Blitter;
import org.apache.harmony.awt.gl.render.JavaArcRasterizer;
@@ -145,7 +147,10 @@
protected Font font = new Font("Dialog", Font.PLAIN, 12);; //$NON-NLS-1$
- protected TextRenderer jtr = JavaTextRenderer.inst;
+ protected TextRenderer jtr =
+ FontManager.IS_FONTLIB ?
+ FLTextRenderer.getInstance() :
+ JavaTextRenderer.inst;
// Current graphics transform
protected AffineTransform transform = new AffineTransform();
@@ -1129,4 +1134,4 @@
//copy.origTransform = new AffineTransform(origTransform);
copy.origPoint = new Point(origPoint);
}
-}
\ No newline at end of file
+}
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java Sun Jun 10 22:15:33 2007
@@ -27,6 +27,8 @@
import java.util.ArrayList;
import java.util.Locale;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
import org.apache.harmony.awt.gl.image.BufferedImageGraphics2D;
/**
@@ -57,11 +59,11 @@
@Override
public Font[] getAllFonts() {
- return CommonGraphics2DFactory.inst.getFontManager().getAllFonts();
+ return FontManager.getInstance().getAllFonts();
}
@Override
public String[] getAvailableFontFamilyNames() {
- return CommonGraphics2DFactory.inst.getFontManager().getAllFamilies();
+ return FontManager.getInstance().getAllFamilies();
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java Sun Jun 10 22:15:33 2007
@@ -21,6 +21,7 @@
package org.apache.harmony.awt.gl.font;
import java.awt.Font;
+import java.awt.GraphicsEnvironment;
import java.awt.peer.FontPeer;
import java.io.File;
import java.io.FileInputStream;
@@ -34,16 +35,20 @@
import java.util.Vector;
import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
+import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
public abstract class FontManager {
+ public static final boolean IS_FONTLIB = "true".equals(System.getProperty("java.awt.fontlib")) ||
+ GraphicsEnvironment.isHeadless();
+
/**
* array of font families names
*/
public String[] allFamilies;
- public static final String DEFAULT_NAME = "Default"; /* Default font name */ //$NON-NLS-1$
+ public static final String DEFAULT_NAME = IS_FONTLIB ? "Luxi Sans" : "Default"; /* Default font name */ //$NON-NLS-1$
public static final String DIALOG_NAME = "Dialog"; /* Dialog font name */ //$NON-NLS-1$
/**
@@ -197,13 +202,16 @@
public Hashtable<String, Vector<FontProperty>> fProperties = new Hashtable<String, Vector<FontProperty>>();
public FontManager(){
- allFamilies = getAllFamilies();
- /*
- * Creating and registering shutdown hook to free resources
- * before object is destroyed.
- */
- DisposeNativeHook shutdownHook = new DisposeNativeHook();
- Runtime.getRuntime().addShutdownHook(shutdownHook);
+
+ if (!IS_FONTLIB) {
+ allFamilies = getAllFamilies();
+ /*
+ * Creating and registering shutdown hook to free resources
+ * before object is destroyed.
+ */
+ DisposeNativeHook shutdownHook = new DisposeNativeHook();
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ }
}
/**
@@ -214,7 +222,7 @@
/**
* Locale - Language ID hash table.
*/
- Hashtable<String, Short> tableLCID = new Hashtable<String, Short>();
+ protected Hashtable<String, Short> tableLCID = new Hashtable<String, Short>();
/**
* Hash table that contains FontPeers instances.
@@ -231,7 +239,10 @@
/**
* Singleton instance
*/
- public final static FontManager inst = CommonGraphics2DFactory.inst.getFontManager();
+ private static FontManager inst =
+ IS_FONTLIB ?
+ new FLFontManager() :
+ CommonGraphics2DFactory.inst.getFontManager();
/**
@@ -305,7 +316,7 @@
* @param logicalIndex index of the logical face name in LOGICAL_FONT_FACES
* array or -1 if desired font peer is not logical.
*/
- private FontPeer createFontPeer(String name, int style, int size, int logicalIndex){
+ protected FontPeer createFontPeer(String name, int style, int size, int logicalIndex){
FontPeer peer;
if (logicalIndex != -1){
peer = createLogicalFontPeer(name, style, size);
@@ -765,7 +776,7 @@
* Class contains SoftReference instance that can be stored in the
* Hashtable by means of key field corresponding to it.
*/
- private class HashMapReference extends SoftReference<FontPeer> {
+ protected class HashMapReference extends SoftReference<FontPeer> {
/**
* The key for Hashtable.
@@ -808,5 +819,6 @@
}
}
+
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java Sun Jun 10 22:15:33 2007
@@ -84,7 +84,7 @@
this.maxAscent = ascent;
this.maxDescent = descent;
this.maxAdvance = lm.getLogicalMaxCharWidth();
- initWidths();
+// initWidths();
}
/**
@@ -134,9 +134,9 @@
*/
@Override
public int charWidth(int ch) {
- if (ch < 256){
- return widths[ch];
- }
+// if (ch < 256){
+// return widths[ch];
+// }
return getFontPeer().charWidth((char)ch);
}
@@ -151,9 +151,9 @@
*/
@Override
public int charWidth(char ch) {
- if (ch < 256){
- return widths[ch];
- }
+// if (ch < 256){
+// return widths[ch];
+// }
return (int)(getFontPeer().charWidth(ch)*scaleX);
}
@@ -202,6 +202,10 @@
*/
@Override
public int[] getWidths() {
+ this.widths = new int[256];
+ for (int chr=0; chr < 256; chr++){
+ widths[chr] = (int)(getFontPeer().charWidth((char)chr)*scaleX);
+ }
return this.widths;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java Sun Jun 10 22:15:33 2007
@@ -21,12 +21,11 @@
package org.apache.harmony.awt.gl.font;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
-
-import java.awt.font.FontRenderContext;
-import java.awt.font.LineMetrics;
import java.util.ArrayList;
import java.util.Locale;
@@ -53,16 +52,16 @@
float height;
// the style of this font peer
- int style;
+ protected int style;
// the point size of this font peer (in pixels)
- int size;
+ protected int size;
// the logical hight of this font peer (in pixels)
int logicalHeight;
// the name of this font peer
- String name;
+ protected String name;
// family name of this font peer
String fontFamilyName;
@@ -71,7 +70,7 @@
String faceName;
// bounds rectanlge of the largest character in this font peer
- Rectangle2D maxCharBounds;
+ protected Rectangle2D maxCharBounds;
// italic angle value of this font peer
float italicAngle = 0.0f;
@@ -80,13 +79,13 @@
int numGlyphs = 0;
// native font handle
- long pFont;
+ protected long pFont;
// cached line metrics object
- LineMetricsImpl nlm;
+ protected LineMetricsImpl nlm = null;
// the postscript name of this font peer
- String psName = null;
+ protected String psName = null;
/**
* Default glyph index, that is used, when the desired glyph
@@ -402,6 +401,9 @@
* Returns cached LineMetrics object of this font peer.
*/
public LineMetrics getLineMetrics(){
+ if (nlm == null) {
+ nlm = (LineMetricsImpl) getLineMetrics("", null, AffineTransform.getTranslateInstance(0,0));
+ }
return nlm;
}
@@ -458,6 +460,10 @@
if (newType == FontManager.FONT_TYPE_T1 || newType == FontManager.FONT_TYPE_TT){
fontType = newType;
}
+ }
+
+ public char getUnicodeByIndex(int glyphCode) {
+ return 0;
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java Sun Jun 10 22:15:33 2007
@@ -28,13 +28,13 @@
public abstract class Glyph{
// character of the glyph
- char glChar;
+ protected char glChar;
// precise glyph metrics
- GlyphMetrics glMetrics;
+ protected GlyphMetrics glMetrics;
// glyph metrics in pixels
- GlyphMetrics glPointMetrics;
+ protected GlyphMetrics glPointMetrics;
// glyph code of this Glyph
int glCode;
@@ -55,7 +55,7 @@
BufferedImage image;
// shape that representing the outline of this glyph
- Shape glOutline = null;
+ protected Shape glOutline = null;
/**
* image bitmap parameters
@@ -94,14 +94,14 @@
* Retruns precise width of this glyph object
*/
public int getWidth(){
- return Math.round((float)glMetrics.getBounds2D().getWidth());
+ return Math.round((float)getGlyphMetrics().getBounds2D().getWidth());
}
/**
* Retruns precise height of this glyph object
*/
public int getHeight(){
- return Math.round((float)glMetrics.getBounds2D().getHeight());
+ return Math.round((float)getGlyphMetrics().getBounds2D().getHeight());
}
/**
@@ -150,9 +150,9 @@
*/
public int[] getABC(){
int[] abc = new int[3];
- abc[0] = (int)glMetrics.getLSB();
- abc[1] = (int)glMetrics.getBounds2D().getWidth();
- abc[2] = (int)glMetrics.getRSB();
+ abc[0] = (int)getGlyphMetrics().getLSB();
+ abc[1] = (int)getGlyphMetrics().getBounds2D().getWidth();
+ abc[2] = (int)getGlyphMetrics().getRSB();
return abc;
}
@@ -194,14 +194,14 @@
* Returns height of the glyph in points.
*/
public int getPointHeight(){
- return (int)glPointMetrics.getBounds2D().getHeight();
+ return (int)getGlyphPointMetrics().getBounds2D().getHeight();
}
/**
* Returns width of the glyph in points.
*/
public int getPointWidth(){
- return (int)glPointMetrics.getBounds2D().getWidth();
+ return (int)getGlyphPointMetrics().getBounds2D().getWidth();
}
public Shape getShape(){
@@ -232,5 +232,6 @@
public abstract Shape initOutline(char c);
}
+
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java Sun Jun 10 22:15:33 2007
@@ -25,6 +25,7 @@
import org.apache.harmony.awt.gl.MultiRectArea;
import org.apache.harmony.awt.gl.Utils;
import org.apache.harmony.awt.gl.Surface;
+import org.apache.harmony.awt.gl.font.FontManager;
import org.apache.harmony.awt.gl.render.NullBlitter;
import org.apache.harmony.awt.wtk.NativeWindow;
import org.apache.harmony.awt.nativebridge.Int32Pointer;
@@ -197,7 +198,9 @@
blitter = OGLBlitter.getInstance();
- jtr = new OGLTextRenderer();
+ if (!FontManager.IS_FONTLIB) {
+ jtr = new OGLTextRenderer();
+ }
}
public OGLGraphics2D(NativeWindow nwin, int tx, int ty, int width, int height) {
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java Sun Jun 10 22:15:33 2007
@@ -82,7 +82,7 @@
blitter = XBlitter.getInstance();
Rectangle bounds = clip.getBounds();
dstSurf = new XSurface(this, bounds.width, bounds.height);
- jtr = DrawableTextRenderer.inst;
+// jtr = DrawableTextRenderer.inst;
//setTransformedClip(clip);
setClip(clip);
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java Sun Jun 10 22:15:33 2007
@@ -39,7 +39,9 @@
import org.apache.harmony.awt.gl.CommonGraphics2D;
import org.apache.harmony.awt.gl.MultiRectArea;
+import org.apache.harmony.awt.gl.font.FontManager;
import org.apache.harmony.awt.gl.font.NativeFont;
+import org.apache.harmony.awt.gl.font.fontlib.FLTextRenderer;
import org.apache.harmony.awt.wtk.NativeWindow;
@@ -92,8 +94,10 @@
size = new Dimension(b.width, b.height);
gi = createGraphicsInfo(this.nw.getId(), tx, ty, b.width, b.height);
- setTransformedClip(this.clip);
- jtr = GDIPTextRenderer.inst;
+ setTransformedClip(this.clip);
+ if (!FontManager.IS_FONTLIB) {
+ jtr = GDIPTextRenderer.inst;
+ }
dstSurf = new GDISurface(gi);
blitter = GDIBlitter.getInstance();
setTransform(getTransform());
@@ -107,8 +111,9 @@
gi = createGraphicsInfo(this.nw.getId(), tx, ty, width, height);
setTransformedClip(this.clip);
- jtr = GDIPTextRenderer.inst;
-
+ if (!FontManager.IS_FONTLIB) {
+ jtr = GDIPTextRenderer.inst;
+ }
dstSurf = new GDISurface(gi);
blitter = GDIBlitter.getInstance();
if (debugOutput) {
@@ -134,18 +139,22 @@
setTransformedClip(this.clip);
dstSurf = img.getImageSurface();
blitter = GDIBlitter.getInstance();
- jtr = GDIPTextRenderer.inst;
+ if (!FontManager.IS_FONTLIB) {
+ jtr = GDIPTextRenderer.inst;
+ }
setTransform(getTransform());
}
@Override
public void addRenderingHints(Map<?,?> hints) {
super.addRenderingHints(hints);
- Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
- if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
- NativeFont.setAntialiasing(gi,true);
- } else {
- NativeFont.setAntialiasing(gi,false);
+ if (!FontManager.IS_FONTLIB) {
+ Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+ if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
+ NativeFont.setAntialiasing(gi,true);
+ } else {
+ NativeFont.setAntialiasing(gi,false);
+ }
}
}
@@ -563,22 +572,26 @@
@Override
public void setRenderingHint(RenderingHints.Key key, Object value) {
super.setRenderingHint(key,value);
- Object val = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
- if (val == RenderingHints.VALUE_ANTIALIAS_ON) {
- NativeFont.setAntialiasing(gi,true);
- } else {
- NativeFont.setAntialiasing(gi,false);
+ if (!FontManager.IS_FONTLIB) {
+ Object val = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+ if (val == RenderingHints.VALUE_ANTIALIAS_ON) {
+ NativeFont.setAntialiasing(gi,true);
+ } else {
+ NativeFont.setAntialiasing(gi,false);
+ }
}
}
@Override
public void setRenderingHints(Map<?,?> hints) {
super.setRenderingHints(hints);
- Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
- if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
- NativeFont.setAntialiasing(gi,true);
- } else {
- NativeFont.setAntialiasing(gi,false);
+ if (!FontManager.IS_FONTLIB) {
+ Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+ if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
+ NativeFont.setAntialiasing(gi,true);
+ } else {
+ NativeFont.setAntialiasing(gi,false);
+ }
}
}
@@ -606,4 +619,4 @@
WinGDIPGraphics2D.gdiPlusShutdown(WinGDIPGraphics2D.gdipToken);
}
}
-}
\ No newline at end of file
+}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c Sun Jun 10 22:15:33 2007
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <netinet/in.h>
#endif
+#include <sys/poll.h>
#include <netinet/in_systm.h>
#include<netinet/ip.h>
#include<netinet/ip_icmp.h>
@@ -37,27 +38,18 @@
unsigned short ip_checksum(unsigned short * buffer, int size);
void set_icmp_packet(struct icmp * icmp_hdr, int packet_size);
-//Alternative Select function
+// Alternative Select function
int
selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept){
PORT_ACCESS_FROM_ENV (env);
- hytimeval_struct timeP;
- hyfdset_t fdset_read;
I_32 result = 0;
- I_32 size = 0;
- if (0 <= uSecTime)
- hysock_timeval_init (0, uSecTime, &timeP);
-
- fdset_read = hymem_allocate_memory(sizeof (struct hyfdset_struct));
- FD_ZERO (&fdset_read->handle);
- FD_SET (hysocketP->sock, &fdset_read->handle);
- size =hysocketP->sock + 1;
-
- if (0 <= uSecTime)
- result = hysock_select (size, fdset_read, NULL, NULL,&timeP);
- else
- result = hysock_select (size, fdset_read, NULL, NULL,NULL);
- hymem_free_memory(fdset_read);
+ struct pollfd my_pollfd;
+
+ my_pollfd.fd = hysocketP->sock;
+ my_pollfd.events = POLLIN | POLLPRI;
+ my_pollfd.revents = 0;
+ result = poll (&my_pollfd, 1, TO_MILLIS(0, uSecTime));
+
return result;
}
@@ -67,8 +59,7 @@
struct icmp * send_buf = 0;
struct ip * recv_buf = 0;
int result,ret=UNREACHABLE;
- struct timeval timeP;
- fd_set * fdset_read = NULL;
+ struct pollfd my_pollfd;
int sockadd_size = sizeof (source);
jbyte host[HYSOCK_INADDR6_LEN];
U_32 length = (*env)->GetArrayLength (env,address);
@@ -103,7 +94,8 @@
send_buf = (struct icmp*)malloc(sizeof(char)*ICMP_SIZE);
recv_buf = (struct ip*)malloc(sizeof(char)*PACKET_SIZE);
if (NULL == send_buf || NULL == recv_buf){
- return NOPRIVILEGE;
+ ret = NOPRIVILEGE;
+ goto cleanup;
}
set_icmp_packet(send_buf, ICMP_SIZE);
@@ -111,15 +103,16 @@
(struct sockaddr*)&dest, sizeof(dest))){
goto cleanup;
}
- //set select timeout, change millisecond to usec
- memset (&timeP, 0, sizeof (struct timeval));
- timeP.tv_sec = timeout/1000;
- timeP.tv_usec = timeout%1000*1000;
- result = select (sock+1, fdset_read, NULL, NULL,&timeP);
- fdset_read = (fd_set *)malloc(sizeof (fd_set));
- FD_ZERO (fdset_read);
- FD_SET (sock, fdset_read);
- result = select (sock+1, fdset_read, NULL, NULL,&timeP);
+
+ //don't ask what is it - just kinda sleep
+ my_pollfd.fd = 0;
+ my_pollfd.events = 0;
+ result = poll(&my_pollfd, 1, timeout);
+
+ my_pollfd.fd = sock;
+ my_pollfd.events = POLLIN | POLLPRI;
+ result = poll(&my_pollfd, 1, timeout);
+
if (SOCKET_ERROR == result || 0 == result){
goto cleanup;
}
@@ -141,9 +134,15 @@
}
ret = REACHABLE;
cleanup:
- free(fdset_read);
- free(send_buf);
- free(recv_buf);
+
+ if (send_buf != NULL) {
+ free(send_buf);
+ }
+
+ if (recv_buf != NULL) {
+ free(recv_buf);
+ }
+
return ret;
}
@@ -188,85 +187,65 @@
(JNIEnv * env, jclass thisClz, jobjectArray readFDArray, jobjectArray writeFDArray,
jint countReadC, jint countWriteC, jintArray outFlags, jlong timeout){
PORT_ACCESS_FROM_ENV (env);
- hytimeval_struct timeP;
I_32 result = 0;
- I_32 size = 0;
- jobject gotFD;
- hyfdset_t fdset_read,fdset_write;
hysocket_t hysocketP;
jboolean isCopy ;
jint *flagArray;
int val;
- U_32 time_sec = (U_32)timeout/1000;
- U_32 time_msec = (U_32)(timeout%1000)*1000;
+ struct pollfd * my_pollfds;
+ int n_pollfds;
+ jobject gotFD;
- fdset_read = hymem_allocate_memory(sizeof (struct hyfdset_struct));
- fdset_write = hymem_allocate_memory(sizeof (struct hyfdset_struct));
-
- FD_ZERO (&fdset_read->handle);
- FD_ZERO (&fdset_write->handle);
- for (val = 0; val<countReadC; val++){
- gotFD = (*env)->GetObjectArrayElement(env,readFDArray,val);
+ n_pollfds = countReadC + countWriteC;
+
+ my_pollfds = hymem_allocate_memory(sizeof(struct pollfd) * n_pollfds);
+ if (my_pollfds == NULL) {
+ return HYPORT_ERROR_SYSTEMFULL;
+ }
+
+ for (val=0; val<countReadC; val++) {
+ gotFD = (*env)->GetObjectArrayElement(env, readFDArray, val);
hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, gotFD);
- /*No difference between ipv4 and ipv6 as in windows*/
- FD_SET (hysocketP->sock, &fdset_read->handle);
- if (0 > (size - hysocketP->sock))
- size = hysocketP->sock;
- }
- for (val = 0; val<countWriteC; val++){
- gotFD = (*env)->GetObjectArrayElement(env,writeFDArray,val);
+
+ my_pollfds[val].fd = hysocketP->sock;
+ my_pollfds[val].events = POLLIN | POLLPRI;
+ my_pollfds[val].revents = 0;
+ }
+
+ for (val=0; val<countWriteC; val++) {
+ gotFD = (*env)->GetObjectArrayElement(env, writeFDArray, val);
hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, gotFD);
- /*No difference between ipv4 and ipv6 as in windows*/
- FD_SET (hysocketP->sock, &fdset_write->handle);
- if (0 > (size - hysocketP->sock))
- size = hysocketP->sock;
- }
- /* the size is the max_fd + 1 */
- size =size + 1;
-
- if (0 > size)
- {
- result = HYPORT_ERROR_SOCKET_FDSET_SIZEBAD;
- }
- else
- {
- /* only set when timeout >= 0 (non-block)*/
- if (0 <= timeout){
- hysock_timeval_init (time_sec, time_msec, &timeP);
- result = hysock_select (size, fdset_read, fdset_write, NULL,&timeP);
- }
- else{
- result = hysock_select (size, fdset_read, fdset_write, NULL,NULL);
- }
- }
-
- if (0 < result){
- /*output the reslut to a int array*/
+
+ my_pollfds[countReadC + val].fd = hysocketP->sock;
+ my_pollfds[countReadC + val].events = POLLOUT;
+ my_pollfds[countReadC + val].revents = 0;
+ }
+
+ result = poll(my_pollfds, n_pollfds, timeout);
+
+ if (result > 0) {
+ /* output result to int array */
flagArray = (*env)->GetIntArrayElements(env,outFlags, &isCopy);
- for (val=0;val<countReadC;val++){
- gotFD = (*env)->GetObjectArrayElement(env,readFDArray,val);
- hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, gotFD);
- if (FD_ISSET(hysocketP->sock,&fdset_read->handle))
- flagArray[val] = SOCKET_OP_READ;
- else
- flagArray[val] = SOCKET_OP_NONE;
-
- }
-
- for (val=0;val<countWriteC;val++){
- gotFD = (*env)->GetObjectArrayElement(env,writeFDArray,val);
- hysocketP = getJavaIoFileDescriptorContentsAsAPointer (env, gotFD);
- if (FD_ISSET(hysocketP->sock,&fdset_write->handle))
- flagArray[val+countReadC] = SOCKET_OP_WRITE;
- else
- flagArray[val+countReadC] = SOCKET_OP_NONE;
-
- }
- (*env)->ReleaseIntArrayElements(env,outFlags, flagArray, 0);
- }
- hymem_free_memory(fdset_write);
- hymem_free_memory(fdset_read);
- /* return both correct and error result, let java code handle the exception*/
+ for (val=0; val<countReadC; val++) {
+ if (my_pollfds[val].revents & (POLLIN | POLLPRI)) {
+ flagArray[val] = SOCKET_OP_READ;
+ } else {
+ flagArray[val] = SOCKET_OP_NONE;
+ }
+ }
+
+ for (val=0; val<countWriteC; val++) {
+ if (my_pollfds[val+countReadC].revents & POLLOUT) {
+ flagArray[val+countReadC] = SOCKET_OP_WRITE;
+ } else {
+ flagArray[val+countReadC] = SOCKET_OP_NONE;
+ }
+ }
+ (*env)->ReleaseIntArrayElements(env, outFlags, flagArray, 0);
+ }
+ hymem_free_memory(my_pollfds);
+
+ /* return both correct and error result, let java code handle exceptions */
return result;
};
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.drl Sun Jun 10 22:15:33 2007
@@ -1 +1,4 @@
org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
+
+#HARMONY-4116
+org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86.ibm Sun Jun 10 22:15:33 2007
@@ -1 +1,3 @@
org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
+#HARMONY-4116
+org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/make/exclude.linux.x86_64.drl Sun Jun 10 22:15:33 2007
@@ -1 +1,3 @@
org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java
+#HARMONY-4116
+org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/unix/hysock.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/unix/hysock.h?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/unix/hysock.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/include/unix/hysock.h Sun Jun 10 22:15:33 2007
@@ -60,6 +60,8 @@
#define NO_R (defined(MACOSX))
/* OTHER_R: everything else */
#define OTHER_R ((!HOSTENT_DATA_R)&&(!GLIBC_R)&&(!ORIGINAL_R)&&(!NO_R))
+/* Converts (seconds, microseconds) to milliseconds */
+#define TO_MILLIS(sec, microsec) (sec * 1000 + (microsec + 999) / 1000)
/* os types */
typedef int OSSOCKET; /* as returned by socket() */
typedef struct sockaddr_in OSSOCKADDR; /* as used by bind() and friends */
Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysock.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysock.c?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysock.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysock.c Sun Jun 10 22:15:33 2007
@@ -2,7 +2,7 @@
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
@@ -33,6 +33,7 @@
#include <errno.h>
#include <sys/types.h>
+#include <sys/poll.h>
#include <sys/socket.h>
#include <netinet/in.h> /* for struct in_addr */
#include <arpa/inet.h> /* for inet_addr */
@@ -100,16 +101,6 @@
#define VALIDATE_ALLOCATIONS 1
-/* needed for connect_with_timeout */
-typedef struct selectFDSet_struct
-{
- int nfds;
- int sock;
- fd_set writeSet;
- fd_set readSet;
- fd_set exceptionSet;
-} selectFDSet_struct;
-
#define CDEV_CURRENT_FUNCTION _prototypes_private
I_32 platformSocketOption (I_32 portableSocketOption);
@@ -2571,6 +2562,11 @@
I_32 rc = 0;
I_32 result = 0;
+ if (nfds >= FD_SETSIZE) {
+ rc = portLibrary->error_set_last_error(portLibrary, errno,
+ HYPORT_ERROR_SOCKET_UNIX_EINVAL);
+ return -1;
+ }
result = select (nfds,
readfds == NULL ? NULL : &readfds->handle,
writefds == NULL ? NULL : &writefds->handle,
@@ -2609,7 +2605,6 @@
* The portable version of a read operation is a blocking call (will wait indefinitely for data).
* This function should be called prior to a read operation, to provide a read timeout.
* If the result is 1, the caller is guaranteed to be able to complete a read on the socket without blocking.
- * The actual contents of the fdset are not available for inspection (as provided in the more general 'select' function).
* The timeout is specified in seconds and microseconds.
* If the timeout is 0, skip this function (and thus the caller of a subsequent read operation may block).
*
@@ -2628,42 +2623,40 @@
hysock_select_read (struct HyPortLibrary * portLibrary, hysocket_t hysocketP,
I_32 secTime, I_32 uSecTime, BOOLEAN accept)
{
- hytimeval_struct timeP;
- I_32 result = 0;
- I_32 size = 0, flags = 0;
- PortlibPTBuffers_t ptBuffers;
+ // Current implementation uses poll() system routine since select()
+ // has issues if fd_num is greater than FD_SETSIZE. See HARMONY-4077.
- ptBuffers = hyport_tls_get (portLibrary);
- if (NULL == ptBuffers)
- {
- return HYPORT_ERROR_SOCKET_SYSTEMFULL;
- }
-
-/* The max fdset size per process is always expected to be less than a 32bit integer value.
- * Is this valid on a 64bit platform?
- */
-
- /* Removed check for zero timeout */
+ int poll_timeout;
+ I_32 result = 0;
+ I_32 rc = 0;
+ struct pollfd my_pollfd;
- result = hysock_fdset_init (portLibrary, hysocketP);
- if (0 != result)
- {
- return result;
- }
+ my_pollfd.fd = SOCKET_CAST(hysocketP);
+ my_pollfd.events = POLLIN | POLLPRI;
+ my_pollfd.revents = 0;
+ poll_timeout = TO_MILLIS(secTime, uSecTime);
+
+ result = poll(&my_pollfd, 1, poll_timeout);
+
+ if (result == -1) {
+ HYSOCKDEBUG ("<poll failed, err=%d>\n", errno);
+
+ if (errno == EINTR) {
+ rc = portLibrary->error_set_last_error(portLibrary, errno,
+ HYPORT_ERROR_SOCKET_INTERRUPTED);
+ } else {
+ rc = portLibrary->error_set_last_error(portLibrary, errno,
+ HYPORT_ERROR_SOCKET_OPFAILED);
+ }
+ } else {
+ if (result || poll_timeout == 0) {
+ rc = result;
+ } else {
+ rc = HYPORT_ERROR_SOCKET_TIMEOUT;
+ }
+ }
- hysock_timeval_init (portLibrary, secTime, uSecTime, &timeP);
- size = hysock_fdset_size (portLibrary, hysocketP);
- if (0 > size)
- {
- result = HYPORT_ERROR_SOCKET_FDSET_SIZEBAD;
- }
- else
- {
- result =
- hysock_select (portLibrary, size, ptBuffers->fdset, NULL, NULL,
- &timeP);
- }
- return result;
+ return rc;
}
#undef CDEV_CURRENT_FUNCTION
@@ -4923,7 +4916,10 @@
#if (defined(HAS_RTNETLINK))
struct sockaddr_nl address;
U_32 receiveLength;
+ struct pollfd my_pollfd;
socklen_t addressLength = sizeof (address);
+ int result;
+
for (;;)
{
/* check if we are done */
@@ -4943,24 +4939,17 @@
/*
* if the remainingLength is 0 then there was no messages available in the existing data
- * so read another datagram containing messages we first use a select to make sure we
+ * so read another datagram containing messages we first use a poll to make sure we
* don't block forever if for some reason there is no netlink message to read
*/
if (netlinkContext->remainingLength == 0)
{
- fd_set waitSockets;
- struct timeval waitTime;
- waitTime.tv_sec = NETLINK_READTIMEOUT_SECS;
- waitTime.tv_usec = 0;
- FD_ZERO (&waitSockets);
- FD_SET (netlinkContext->netlinkSocketHandle, &waitSockets);
-
- if (select
- (netlinkContext->netlinkSocketHandle + 1, &waitSockets, NULL,
- NULL, &waitTime) > 0)
- {
-
+ my_pollfd.fd = netlinkContext->netlinkSocketHandle;
+ my_pollfd.events = POLLIN | POLLPRI;
+ my_pollfd.revents = 0;
+
+ if (poll(&my_pollfd, 1, NETLINK_READTIMEOUT_SECS * 1000) > 0) {
struct sockaddr_nl nladdr;
struct msghdr msg;
struct iovec iov;
@@ -5127,38 +5116,12 @@
U_32 step, U_8 ** context)
{
I_32 rc = 0;
- struct timeval passedTimeout;
int errorVal;
int errorValLen = sizeof (int);
+ struct pollfd my_pollfd;
if (HY_PORT_SOCKET_STEP_START == step)
{
- /* initialize the context to a known state */
- if (NULL != context)
- {
- *context = NULL;
- }
- else
- {
- /* this should never happen but just in case */
- return HYPORT_ERROR_SOCKET_NORECOVERY;
- }
-
- /* we will be looping checking for when we are connected so allocate the descriptor sets that we will use */
- *context =
- (U_8 *) portLibrary->mem_allocate_memory (portLibrary,
- sizeof (struct
- selectFDSet_struct));
-#if (defined(VALIDATE_ALLOCATIONS))
- if (NULL == *context)
- {
- return HYPORT_ERROR_SOCKET_NOBUFFERS;
- }
-#endif
-
- ((struct selectFDSet_struct *) *context)->sock = SOCKET_CAST (sock);
- ((struct selectFDSet_struct *) *context)->nfds = SOCKET_CAST (sock) + 1;
-
/* set the socket to non-blocking */
rc = hysock_set_nonblocking (portLibrary, sock, TRUE);
if (0 != rc)
@@ -5166,14 +5129,13 @@
return rc;
}
- rc =
- connect (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
- sizeof (addr->addr));
+ rc = connect
+ (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
+ sizeof (addr->addr));
if (rc < 0)
{
rc = errno;
- switch (rc)
- {
+ switch (rc) {
case HYPORT_ERROR_SOCKET_UNIX_EINTR:
return HYPORT_ERROR_SOCKET_ALREADYBOUND;
case HYPORT_ERROR_SOCKET_UNIX_EAGAIN:
@@ -5186,54 +5148,32 @@
return rc;
}
- /* we connected right off the bat so just return */
- return rc;
+ /* we connected right off the bat so just return */
+ return rc;
- }
- else if (HY_PORT_SOCKET_STEP_CHECK == step)
- {
+ }
+ else if (HY_PORT_SOCKET_STEP_CHECK == step)
+ {
/* now check if we have connected yet */
/* set the timeout value to be used. Because on some unix platforms we don't get notified when a socket
is closed we only sleep for 100ms at a time */
- passedTimeout.tv_sec = 0;
- if (timeout > 100)
- {
- passedTimeout.tv_usec = 100 * 1000;
- }
- else if ((I_32)timeout >= 0)
- {
- passedTimeout.tv_usec = timeout * 1000;
- }
+ timeout = timeout > 100 ? 100 : timeout;
/* initialize the FD sets for the select */
- FD_ZERO (&(((struct selectFDSet_struct *) *context)->exceptionSet));
- FD_ZERO (&(((struct selectFDSet_struct *) *context)->writeSet));
- FD_ZERO (&(((struct selectFDSet_struct *) *context)->readSet));
- FD_SET (((struct selectFDSet_struct *) *context)->sock,
- &(((struct selectFDSet_struct *) *context)->writeSet));
- FD_SET (((struct selectFDSet_struct *) *context)->sock,
- &(((struct selectFDSet_struct *) *context)->readSet));
- FD_SET (((struct selectFDSet_struct *) *context)->sock,
- &(((struct selectFDSet_struct *) *context)->exceptionSet));
- rc =
- select (((struct selectFDSet_struct *) *context)->nfds,
- &(((struct selectFDSet_struct *) *context)->readSet),
- &(((struct selectFDSet_struct *) *context)->writeSet),
- &(((struct selectFDSet_struct *) *context)->exceptionSet),
- (I_32)timeout >= 0 ? &passedTimeout : NULL);
+ my_pollfd.fd = SOCKET_CAST(sock);
+ my_pollfd.events = POLLIN | POLLPRI | POLLOUT;
+ my_pollfd.revents = 0;
+ rc = poll(&my_pollfd, 1, timeout);
+
/* if there is at least one descriptor ready to be checked */
if (0 < rc)
{
/* if the descriptor is in the write set then we have connected or failed */
- if (FD_ISSET
- (((struct selectFDSet_struct *) *context)->sock,
- &(((struct selectFDSet_struct *) *context)->writeSet)))
- {
- if (!FD_ISSET
- (((struct selectFDSet_struct *) *context)->sock,
- &(((struct selectFDSet_struct *) *context)->readSet)))
+
+ if (my_pollfd.revents & POLLOUT) {
+ if (!(my_pollfd.revents & (POLLIN | POLLPRI)))
{
/* ok we have connected ok */
return 0;
@@ -5241,39 +5181,28 @@
else
{
/* ok we have more work to do to figure it out */
- if (getsockopt
- (((struct selectFDSet_struct *) *context)->sock,
- SOL_SOCKET, SO_ERROR, (char *) &errorVal,
- &errorValLen) >= 0)
- {
- return errorVal ? findError(errorVal):0;
- }
- else
- {
+ if (getsockopt (SOCKET_CAST(sock), SOL_SOCKET, SO_ERROR,
+ (char *) &errorVal, &errorValLen) >= 0) {
+ return errorVal ? findError(errorVal):0;
+ } else {
rc = errno;
return portLibrary->error_set_last_error (portLibrary,
rc,
- findError
- (rc));
- }
- }
- }
+ findError(rc));
+ }
+ }
+ }
/* if the descriptor is in the exception set then the connect failed */
- if (FD_ISSET
- (((struct selectFDSet_struct *) *context)->sock,
- &(((struct selectFDSet_struct *) *context)->exceptionSet)))
- {
- if (getsockopt
- (((struct selectFDSet_struct *) *context)->sock, SOL_SOCKET,
- SO_ERROR, (char *) &errorVal, &errorValLen) >= 0)
- {
- return errorVal ? findError(errorVal):0;
- }
+ if (my_pollfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
+ if (getsockopt(SOCKET_CAST(sock), SOL_SOCKET, SO_ERROR,
+ (char *) &errorVal, &errorValLen) >= 0) {
+ return errorVal ? findError(errorVal):0;
+ }
rc = errno;
return portLibrary->error_set_last_error (portLibrary, rc,
findError (rc));
- }
+ }
}
else if (rc < 0)
@@ -5290,26 +5219,20 @@
/* some other error occured so look it up and return */
return portLibrary->error_set_last_error (portLibrary, rc,
findError (rc));
- }
+ }
/* if we get here the timeout expired or the connect had not yet completed
- just indicate that the connect is not yet complete */
+ just indicate that the connect is not yet complete */
return HYPORT_ERROR_SOCKET_NOTCONNECTED;
}
else if (HY_PORT_SOCKET_STEP_DONE == step)
{
- /* we are done the connect or an error occured so clean up */
- if (sock != INVALID_SOCKET)
- {
- hysock_set_nonblocking (portLibrary, sock, FALSE);
- }
-
- /* free the memory for the FD set */
- if ((context != NULL) && (*context != NULL))
- {
- portLibrary->mem_free_memory (portLibrary, *context);
- }
- return 0;
+ /* we are done the connect or an error occured so clean up */
+ if (sock != INVALID_SOCKET)
+ {
+ hysock_set_nonblocking (portLibrary, sock, FALSE);
+ }
+ return 0;
}
return HYPORT_ERROR_SOCKET_ARGSINVALID;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile?view=diff&rev=546011&r1=546010&r2=546011
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/native/prefs/windows/makefile Sun Jun 10 22:15:33 2007
@@ -37,8 +37,7 @@
!ENDIF
MDLLIBFILES = $(MDLLIBFILES) \
- $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
+ $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
DLLBASE=0x13300000
COMMENT=/comment:"Preferences component native code. (c) Copyright 1993, 2005 The Apache Software Foundation or its licensors, as applicable."