From: <cr...@us...> - 2009-01-17 15:03:11
|
Revision: 4877 http://jnode.svn.sourceforge.net/jnode/?rev=4877&view=rev Author: crawley Date: 2009-01-17 15:03:04 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Rename the shell.command.unix package and plugin to ...posix Modified Paths: -------------- trunk/all/conf/full-plugin-list.xml trunk/shell/build.xml Added Paths: ----------- trunk/shell/descriptors/org.jnode.shell.command.posix.xml trunk/shell/src/shell/org/jnode/shell/command/posix/ trunk/shell/src/shell/org/jnode/shell/command/posix/FalseCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/TrueCommand.java trunk/shell/src/shell/org/jnode/shell/command/posix/UnixTestCommand.java Removed Paths: ------------- trunk/shell/descriptors/org.jnode.shell.command.unix.xml trunk/shell/src/shell/org/jnode/shell/command/unix/FalseCommand.java trunk/shell/src/shell/org/jnode/shell/command/unix/TrueCommand.java trunk/shell/src/shell/org/jnode/shell/command/unix/UnixTestCommand.java Modified: trunk/all/conf/full-plugin-list.xml =================================================================== --- trunk/all/conf/full-plugin-list.xml 2009-01-17 07:56:28 UTC (rev 4876) +++ trunk/all/conf/full-plugin-list.xml 2009-01-17 15:03:04 UTC (rev 4877) @@ -31,7 +31,7 @@ <plugin id="thinlet"/> - <plugin id="org.jnode.shell.command.unix"/> + <plugin id="org.jnode.shell.command.posix"/> <plugin id="org.jnode.apps.jpartition"/> Modified: trunk/shell/build.xml =================================================================== --- trunk/shell/build.xml 2009-01-17 07:56:28 UTC (rev 4876) +++ trunk/shell/build.xml 2009-01-17 15:03:04 UTC (rev 4877) @@ -10,6 +10,7 @@ <!-- Subproject specific classpath --> <path id="my-cp"> <pathelement location="${jnode-core.jar}"/> + <pathelement location="${basedir}/../builder/lib/nanoxml-2.2.3.jar"/> <path refid="cp"/> </path> Added: trunk/shell/descriptors/org.jnode.shell.command.posix.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.posix.xml (rev 0) +++ trunk/shell/descriptors/org.jnode.shell.command.posix.xml 2009-01-17 15:03:04 UTC (rev 4877) @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.shell.command.posix" + name="JNode System Commands" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + <requires> + <import plugin="org.jnode.shell.help"/> + </requires> + + <runtime> + <library name="jnode-shell.jar"> + <export name="org.jnode.shell.command.posix.*"/> + </library> + </runtime> + + <extension point="org.jnode.shell.aliases"> + <alias name="false" class="org.jnode.shell.command.posix.FalseCommand"/> + <alias name="test" class="org.jnode.shell.command.posix.UnixTestCommand"/> + <alias name="true" class="org.jnode.shell.command.posix.TrueCommand"/> + <alias name="[" class="org.jnode.shell.command.posix.UnixTestCommand"/> + </extension> + + <extension point="org.jnode.shell.syntaxes"> + <syntax alias="false"> + <empty description="Set a non-zero return code"/> + </syntax> + <syntax alias="true"> + <empty description="Set a zero return code"/> + </syntax> + </extension> + + <extension point="org.jnode.security.permissions"> + <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> + <permission class="java.lang.RuntimePermission" name="getProtectionDomain"/> + <permission class="java.lang.RuntimePermission" name="createClassLoader"/> + <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> + <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> + <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> + <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> + <permission class="java.net.SocketPermission" name="*" actions="resolve"/> + <permission class="java.net.SocketPermission" name="*:0-" actions="connect,resolve"/> + <permission class="java.lang.RuntimePermission" name="writeFileDescriptor"/> + <permission class="java.lang.RuntimePermission" name="readFileDescriptor"/> + </extension> + +</plugin> Deleted: trunk/shell/descriptors/org.jnode.shell.command.unix.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.unix.xml 2009-01-17 07:56:28 UTC (rev 4876) +++ trunk/shell/descriptors/org.jnode.shell.command.unix.xml 2009-01-17 15:03:04 UTC (rev 4877) @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plugin SYSTEM "jnode.dtd"> - -<plugin id="org.jnode.shell.command.unix" - name="JNode System Commands" - version="@VERSION@" - license-name="lgpl" - provider-name="JNode.org"> - - <requires> - <import plugin="org.jnode.shell.help"/> - </requires> - - <runtime> - <library name="jnode-shell.jar"> - <export name="org.jnode.shell.command.unix.*"/> - </library> - </runtime> - - <extension point="org.jnode.shell.aliases"> - <alias name="false" class="org.jnode.shell.command.unix.FalseCommand"/> - <alias name="test" class="org.jnode.shell.command.unix.UnixTestCommand"/> - <alias name="true" class="org.jnode.shell.command.unix.TrueCommand"/> - <alias name="[" class="org.jnode.shell.command.unix.UnixTestCommand"/> - </extension> - - <extension point="org.jnode.shell.syntaxes"> - <syntax alias="false"> - <empty description="Set a non-zero return code"/> - </syntax> - <syntax alias="true"> - <empty description="Set a zero return code"/> - </syntax> - </extension> - - <extension point="org.jnode.security.permissions"> - <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> - <permission class="java.lang.RuntimePermission" name="getProtectionDomain"/> - <permission class="java.lang.RuntimePermission" name="createClassLoader"/> - <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> - <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> - <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> - <permission class="java.lang.RuntimePermission" name="exitVM" actions="*" /> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> - <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> - <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> - <permission class="java.net.SocketPermission" name="*" actions="resolve"/> - <permission class="java.net.SocketPermission" name="*:0-" actions="connect,resolve"/> - <permission class="java.lang.RuntimePermission" name="writeFileDescriptor"/> - <permission class="java.lang.RuntimePermission" name="readFileDescriptor"/> - </extension> - -</plugin> Added: trunk/shell/src/shell/org/jnode/shell/command/posix/FalseCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/posix/FalseCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/posix/FalseCommand.java 2009-01-17 15:03:04 UTC (rev 4877) @@ -0,0 +1,47 @@ +/* + * $Id: EchoCommand.java 4694 2008-11-09 14:20:31Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command.posix; + +import org.jnode.shell.AbstractCommand; + +/** + * Simply exit with rc of 1; + * + * @author cr...@jn... + */ +public class FalseCommand extends AbstractCommand { + + public FalseCommand() { + super("Exit with a non-zero return code"); + } + + public static void main(String[] args) throws Exception { + new FalseCommand().execute(args); + } + + /** + * Execute the command + */ + public void execute() throws Exception { + exit(1); + } +} Added: trunk/shell/src/shell/org/jnode/shell/command/posix/TrueCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/posix/TrueCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/posix/TrueCommand.java 2009-01-17 15:03:04 UTC (rev 4877) @@ -0,0 +1,46 @@ +/* + * $Id: EchoCommand.java 4694 2008-11-09 14:20:31Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command.posix; + +import org.jnode.shell.AbstractCommand; + +/** + * Simply exit with rc of 0; + * + * @author cr...@jn... + */ +public class TrueCommand extends AbstractCommand { + + public TrueCommand() { + super("Exit with zero return code"); + } + + public static void main(String[] args) throws Exception { + new TrueCommand().execute(args); + } + + /** + * Execute the command + */ + public void execute() throws Exception { + } +} Added: trunk/shell/src/shell/org/jnode/shell/command/posix/UnixTestCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/posix/UnixTestCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/posix/UnixTestCommand.java 2009-01-17 15:03:04 UTC (rev 4877) @@ -0,0 +1,413 @@ +/* + * $Id: SetCommand.java 2945 2006-12-20 08:51:17Z qades $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command.posix; + +import java.io.File; +import java.io.PrintWriter; +import java.util.HashMap; +import java.util.Stack; + +import org.jnode.shell.AbstractCommand; +import org.jnode.shell.CommandLine; +import org.jnode.shell.help.SyntaxErrorException; + + +/** + * JNode implementation of the UNIX 'test' command + * + * @author cr...@jn... + */ +public class UnixTestCommand extends AbstractCommand { + // FIXME convert to use the new commandline syntax mechanism so that + // we get command completion. + private static class Operator { + public final int opNo; + public final int priority; + public final int kind; + public Operator(final int opNo, final int priority, int kind) { + this.opNo = opNo; + this.priority = priority; + this.kind = kind; + } + } + + private boolean bracketted; + private int pos; + private String[] args; + private int lastArg; + private Stack<Object> operandStack = new Stack<Object>(); + private Stack<Operator> operatorStack = new Stack<Operator>(); + + private static final int OP_DIRECTORY = 1; + private static final int OP_EXISTS = 2; + private static final int OP_FILE = 3; + private static final int OP_STRING_LENGTH = 4; + private static final int OP_STRING_NONEMPTY = 5; + private static final int OP_STRING_EMPTY = 6; + private static final int OP_READABLE = 7; + private static final int OP_WRITEABLE = 8; + private static final int OP_NONEMPTY = 9; + private static final int OP_EQ = 10; + private static final int OP_NE = 11; + private static final int OP_GT = 12; + private static final int OP_GE = 13; + private static final int OP_LT = 14; + private static final int OP_LE = 15; + private static final int OP_AND = 16; + private static final int OP_OR = 17; + private static final int OP_NOT = 18; + private static final int OP_STRING_EQUALS = 19; + private static final int OP_STRING_NONEQUAL = 20; + private static final int OP_LPAREN = 21; + private static final int OP_RPAREN = 22; + private static final int OP_OLDER = 23; + private static final int OP_NEWER = 24; + + private static final int OP_UNARY = 1; + private static final int OP_BINARY = 2; + private static final int OP_SPECIAL = 3; + + private static final HashMap<String, Operator> OPERATOR_MAP; + + static { + OPERATOR_MAP = new HashMap<String, Operator>(); + OPERATOR_MAP.put("-d", new Operator(OP_DIRECTORY, 3, OP_UNARY)); + OPERATOR_MAP.put("-e", new Operator(OP_EXISTS, 3, OP_UNARY)); + OPERATOR_MAP.put("-f", new Operator(OP_FILE, 3, OP_UNARY)); + OPERATOR_MAP.put("-l", new Operator(OP_STRING_LENGTH, 3, OP_UNARY)); + OPERATOR_MAP.put("-n", new Operator(OP_STRING_NONEMPTY, 3, OP_UNARY)); + OPERATOR_MAP.put("-z", new Operator(OP_STRING_EMPTY, 3, OP_UNARY)); + OPERATOR_MAP.put("-r", new Operator(OP_READABLE, 3, OP_UNARY)); + OPERATOR_MAP.put("-w", new Operator(OP_WRITEABLE, 3, OP_UNARY)); + OPERATOR_MAP.put("-eq", new Operator(OP_EQ, 3, OP_BINARY)); + OPERATOR_MAP.put("-ne", new Operator(OP_NE, 3, OP_BINARY)); + OPERATOR_MAP.put("-lt", new Operator(OP_LT, 3, OP_BINARY)); + OPERATOR_MAP.put("-le", new Operator(OP_LE, 3, OP_BINARY)); + OPERATOR_MAP.put("-gt", new Operator(OP_GT, 3, OP_BINARY)); + OPERATOR_MAP.put("-ge", new Operator(OP_GE, 3, OP_BINARY)); + OPERATOR_MAP.put("-ot", new Operator(OP_OLDER, 3, OP_BINARY)); + OPERATOR_MAP.put("-nt", new Operator(OP_NEWER, 3, OP_BINARY)); + OPERATOR_MAP.put("-a", new Operator(OP_AND, 1, OP_BINARY)); + OPERATOR_MAP.put("-o", new Operator(OP_OR, 0, OP_BINARY)); + OPERATOR_MAP.put("!", new Operator(OP_NOT, 2, OP_UNARY)); + OPERATOR_MAP.put("=", new Operator(OP_STRING_EQUALS, 5, OP_BINARY)); + OPERATOR_MAP.put("!=", new Operator(OP_STRING_NONEQUAL, 5, OP_BINARY)); + OPERATOR_MAP.put("(", new Operator(OP_LPAREN, -1, OP_SPECIAL)); + OPERATOR_MAP.put(")", new Operator(OP_RPAREN, 6, OP_SPECIAL)); + } + + public void execute() + throws Exception { + boolean res = false; + CommandLine commandLine = getCommandLine(); + String commandName = commandLine.getCommandName(); + bracketted = (commandName != null && commandName.equals("[")); + args = commandLine.getArguments(); + try { + if (bracketted && args.length == 0) { + throw new SyntaxErrorException("missing ']'"); + } else if (bracketted && !args[args.length - 1].equals("]")) { + processAsOptions(args); + res = true; + } else { + lastArg = bracketted ? args.length - 2 : args.length - 1; + if (lastArg == -1) { + res = false; + } else { + Object obj = evaluate(); + if (pos <= lastArg) { + if (args[pos].equals(")")) { + throw new SyntaxErrorException("unmatched ')'"); + } else { + throw new AssertionError("I'm confused! pos = " + pos + + ", lastArg = " + lastArg + ", next arg is " + args[pos]); + } + } + if (obj instanceof Boolean) { + res = obj == Boolean.TRUE; + } else if (obj instanceof Long) { + res = ((Long) obj).longValue() != 0; + } else { + res = obj.toString().length() > 0; + } + } + } + if (!res) { + exit(1); + } + } catch (SyntaxErrorException ex) { + getError().getPrintWriter().println(ex.getMessage()); + exit(2); + } + } + + private Object evaluate() throws SyntaxErrorException { + evaluateExpression(false); + while (!operatorStack.isEmpty()) { + reduce(); + } + if (operandStack.size() != 1) { + throw new AssertionError("wrong nos operands left"); + } + return operandStack.pop(); + } + + private void evaluateExpression(boolean nested) throws SyntaxErrorException { + evaluatePrimary(nested); + while (pos <= lastArg) { + String tok = next(); + Operator op = OPERATOR_MAP.get(tok); + if (op == null) { + throw new SyntaxErrorException("expected an operator"); + } + switch(op.kind) { + case OP_UNARY: + throw new SyntaxErrorException("misplaced unary operator"); + case OP_BINARY: + evaluatePrimary(nested); + reduceAndPush(op, popOperand()); + break; + case OP_SPECIAL: + if (op.opNo == OP_LPAREN) { + throw new SyntaxErrorException("misplaced '('"); + } else if (op.opNo == OP_RPAREN) { + if (!nested) { + throw new SyntaxErrorException("misplaced ')'"); + } + back(); + return; + } + } + } + } + + private void evaluatePrimary(boolean nested) throws SyntaxErrorException { + String tok = next(); + Operator op = OPERATOR_MAP.get(tok); + if (op == null) { + pushOperand(tok); + } else { + switch (op.kind) { + case OP_UNARY: + operatorStack.push(op); + operandStack.push(next()); + break; + case OP_BINARY: + throw new SyntaxErrorException("misplaced binary operator"); + case OP_SPECIAL: + if (op.opNo == OP_LPAREN) { + operatorStack.push(op); // ... as a marker. + evaluateExpression(true); + if (!next().equals(")")) { + throw new SyntaxErrorException("missing ')'"); + } + while (operatorStack.peek() != op) { + reduce(); + } + if (operatorStack.pop() != op) { + throw new AssertionError("cannot find my marker!"); + } + } else { + throw new SyntaxErrorException("unmatched ')'"); + } + } + } + } + + private void reduceAndPush(Operator operator, Object operand) throws SyntaxErrorException { + while (!operatorStack.isEmpty() && operator.priority <= operatorStack.peek().priority) { + reduce(); + } + operatorStack.push(operator); + operandStack.push(operand); + } + + private void reduce() throws SyntaxErrorException { + Operator operator = operatorStack.pop(); + Object operand = null, operand2 = null; + if (operator.kind == OP_UNARY) { + operand = popOperand(); + } else if (operator.kind == OP_BINARY) { + operand2 = popOperand(); + operand = popOperand(); + } + switch (operator.opNo) { + case OP_EXISTS: + pushOperand(toFile(operand).exists()); + break; + case OP_DIRECTORY: + pushOperand(toFile(operand).isDirectory()); + break; + case OP_FILE: + pushOperand(toFile(operand).isFile()); + break; + case OP_NONEMPTY: + pushOperand(toFile(operand).length() > 0); + break; + case OP_READABLE: + pushOperand(toFile(operand).canRead()); + break; + case OP_WRITEABLE: + pushOperand(toFile(popOperand()).canWrite()); + break; + case OP_OLDER: + pushOperand(toFile(operand).lastModified() < toFile(operand2).lastModified()); + break; + case OP_NEWER: + pushOperand(toFile(operand).lastModified() > toFile(operand2).lastModified()); + break; + case OP_STRING_EMPTY: + pushOperand(toString().length() == 0); + break; + case OP_STRING_NONEMPTY: + pushOperand(toString(operand).length() > 0); + break; + case OP_STRING_LENGTH: + pushOperand(toString(operand).length()); + break; + case OP_EQ: + pushOperand(toNumber(operand) == toNumber(operand2)); + break; + case OP_NE: + pushOperand(toNumber(operand) != toNumber(operand2)); + break; + case OP_LT: + pushOperand(toNumber(operand) < toNumber(operand2)); + break; + case OP_LE: + pushOperand(toNumber(operand) <= toNumber(operand2)); + break; + case OP_GT: + pushOperand(toNumber(operand) > toNumber(operand2)); + break; + case OP_GE: + pushOperand(toNumber(operand) >= toNumber(operand2)); + break; + case OP_AND: + pushOperand(toBoolean(operand) & toBoolean(operand2)); + break; + case OP_OR: + pushOperand(toBoolean(operand) | toBoolean(operand2)); + break; + case OP_NOT: + pushOperand(!toBoolean(operand)); + break; + case OP_STRING_EQUALS: + pushOperand(toString(operand).equals(toString(operand2))); + break; + case OP_STRING_NONEQUAL: + pushOperand(!toString(operand).equals(toString(operand2))); + break; + default: + throw new AssertionError("bad operator"); + } + } + + private void processAsOptions(String[] args) throws SyntaxErrorException { + PrintWriter err = getError().getPrintWriter(); + for (String option : args) { + if (option.equals("--help")) { + err.println("Don't panic!"); + } else if (option.equals("--version")) { + err.println("JNode test 0.0"); + } else { + throw new SyntaxErrorException("unknown option '" + option + "'"); + } + } + } + + private void pushOperand(Object value) { + operandStack.push(value); + } + + private void pushOperand(boolean value) { + operandStack.push(value ? Boolean.TRUE : Boolean.FALSE); + } + + private void pushOperand(long value) { + operandStack.push(new Long(value)); + } + + private Object popOperand() throws SyntaxErrorException { + if (operandStack.isEmpty()) { + throw new SyntaxErrorException("missing LHS for operator"); + } + return operandStack.pop(); + } + + private long toNumber(Object obj) throws SyntaxErrorException { + if (obj instanceof Long) { + return ((Long) obj).longValue(); + } else if (obj instanceof String) { + try { + return Long.parseLong((String) obj); + } catch (NumberFormatException ex) { + throw new SyntaxErrorException( + "operand is not a number: '" + obj.toString() + "'"); + } + } else { + throw new SyntaxErrorException("subexpression is not an INTEGER"); + } + } + + private boolean toBoolean(Object obj) throws SyntaxErrorException { + if (obj instanceof Boolean) { + return obj == Boolean.TRUE; + } else if (obj instanceof String) { + return ((String) obj).length() > 0; + } else { + throw new SyntaxErrorException("operand is an INTEGER"); + } + } + + private String toString(Object obj) throws SyntaxErrorException { + if (obj instanceof String) { + return (String) obj; + } else { + throw new SyntaxErrorException("operand is not a STRING"); + } + } + + private File toFile(Object obj) throws SyntaxErrorException { + if (obj instanceof String) { + return new File((String) obj); + } else { + throw new SyntaxErrorException("operand is not a FILENAME"); + } + } + + private String next() { + if (pos > lastArg) { + return null; + } + return args[pos++]; + } + + private void back() throws SyntaxErrorException { + pos--; + } + + public static void main(String[] args) throws Exception { + // If you invoke it this way you cannot distinguish 'test' from '[' + new UnixTestCommand().execute(args); + } +} Deleted: trunk/shell/src/shell/org/jnode/shell/command/unix/FalseCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/unix/FalseCommand.java 2009-01-17 07:56:28 UTC (rev 4876) +++ trunk/shell/src/shell/org/jnode/shell/command/unix/FalseCommand.java 2009-01-17 15:03:04 UTC (rev 4877) @@ -1,47 +0,0 @@ -/* - * $Id: EchoCommand.java 4694 2008-11-09 14:20:31Z crawley $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.command.unix; - -import org.jnode.shell.AbstractCommand; - -/** - * Simply exit with rc of 1; - * - * @author cr...@jn... - */ -public class FalseCommand extends AbstractCommand { - - public FalseCommand() { - super("Exit with a non-zero return code"); - } - - public static void main(String[] args) throws Exception { - new FalseCommand().execute(args); - } - - /** - * Execute the command - */ - public void execute() throws Exception { - exit(1); - } -} Deleted: trunk/shell/src/shell/org/jnode/shell/command/unix/TrueCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/unix/TrueCommand.java 2009-01-17 07:56:28 UTC (rev 4876) +++ trunk/shell/src/shell/org/jnode/shell/command/unix/TrueCommand.java 2009-01-17 15:03:04 UTC (rev 4877) @@ -1,46 +0,0 @@ -/* - * $Id: EchoCommand.java 4694 2008-11-09 14:20:31Z crawley $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.command.unix; - -import org.jnode.shell.AbstractCommand; - -/** - * Simply exit with rc of 0; - * - * @author cr...@jn... - */ -public class TrueCommand extends AbstractCommand { - - public TrueCommand() { - super("Exit with zero return code"); - } - - public static void main(String[] args) throws Exception { - new TrueCommand().execute(args); - } - - /** - * Execute the command - */ - public void execute() throws Exception { - } -} Deleted: trunk/shell/src/shell/org/jnode/shell/command/unix/UnixTestCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/unix/UnixTestCommand.java 2009-01-17 07:56:28 UTC (rev 4876) +++ trunk/shell/src/shell/org/jnode/shell/command/unix/UnixTestCommand.java 2009-01-17 15:03:04 UTC (rev 4877) @@ -1,413 +0,0 @@ -/* - * $Id: SetCommand.java 2945 2006-12-20 08:51:17Z qades $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.command.unix; - -import java.io.File; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Stack; - -import org.jnode.shell.AbstractCommand; -import org.jnode.shell.CommandLine; -import org.jnode.shell.help.SyntaxErrorException; - - -/** - * JNode implementation of the UNIX 'test' command - * - * @author cr...@jn... - */ -public class UnixTestCommand extends AbstractCommand { - // FIXME convert to use the new commandline syntax mechanism so that - // we get command completion. - private static class Operator { - public final int opNo; - public final int priority; - public final int kind; - public Operator(final int opNo, final int priority, int kind) { - this.opNo = opNo; - this.priority = priority; - this.kind = kind; - } - } - - private boolean bracketted; - private int pos; - private String[] args; - private int lastArg; - private Stack<Object> operandStack = new Stack<Object>(); - private Stack<Operator> operatorStack = new Stack<Operator>(); - - private static final int OP_DIRECTORY = 1; - private static final int OP_EXISTS = 2; - private static final int OP_FILE = 3; - private static final int OP_STRING_LENGTH = 4; - private static final int OP_STRING_NONEMPTY = 5; - private static final int OP_STRING_EMPTY = 6; - private static final int OP_READABLE = 7; - private static final int OP_WRITEABLE = 8; - private static final int OP_NONEMPTY = 9; - private static final int OP_EQ = 10; - private static final int OP_NE = 11; - private static final int OP_GT = 12; - private static final int OP_GE = 13; - private static final int OP_LT = 14; - private static final int OP_LE = 15; - private static final int OP_AND = 16; - private static final int OP_OR = 17; - private static final int OP_NOT = 18; - private static final int OP_STRING_EQUALS = 19; - private static final int OP_STRING_NONEQUAL = 20; - private static final int OP_LPAREN = 21; - private static final int OP_RPAREN = 22; - private static final int OP_OLDER = 23; - private static final int OP_NEWER = 24; - - private static final int OP_UNARY = 1; - private static final int OP_BINARY = 2; - private static final int OP_SPECIAL = 3; - - private static final HashMap<String, Operator> OPERATOR_MAP; - - static { - OPERATOR_MAP = new HashMap<String, Operator>(); - OPERATOR_MAP.put("-d", new Operator(OP_DIRECTORY, 3, OP_UNARY)); - OPERATOR_MAP.put("-e", new Operator(OP_EXISTS, 3, OP_UNARY)); - OPERATOR_MAP.put("-f", new Operator(OP_FILE, 3, OP_UNARY)); - OPERATOR_MAP.put("-l", new Operator(OP_STRING_LENGTH, 3, OP_UNARY)); - OPERATOR_MAP.put("-n", new Operator(OP_STRING_NONEMPTY, 3, OP_UNARY)); - OPERATOR_MAP.put("-z", new Operator(OP_STRING_EMPTY, 3, OP_UNARY)); - OPERATOR_MAP.put("-r", new Operator(OP_READABLE, 3, OP_UNARY)); - OPERATOR_MAP.put("-w", new Operator(OP_WRITEABLE, 3, OP_UNARY)); - OPERATOR_MAP.put("-eq", new Operator(OP_EQ, 3, OP_BINARY)); - OPERATOR_MAP.put("-ne", new Operator(OP_NE, 3, OP_BINARY)); - OPERATOR_MAP.put("-lt", new Operator(OP_LT, 3, OP_BINARY)); - OPERATOR_MAP.put("-le", new Operator(OP_LE, 3, OP_BINARY)); - OPERATOR_MAP.put("-gt", new Operator(OP_GT, 3, OP_BINARY)); - OPERATOR_MAP.put("-ge", new Operator(OP_GE, 3, OP_BINARY)); - OPERATOR_MAP.put("-ot", new Operator(OP_OLDER, 3, OP_BINARY)); - OPERATOR_MAP.put("-nt", new Operator(OP_NEWER, 3, OP_BINARY)); - OPERATOR_MAP.put("-a", new Operator(OP_AND, 1, OP_BINARY)); - OPERATOR_MAP.put("-o", new Operator(OP_OR, 0, OP_BINARY)); - OPERATOR_MAP.put("!", new Operator(OP_NOT, 2, OP_UNARY)); - OPERATOR_MAP.put("=", new Operator(OP_STRING_EQUALS, 5, OP_BINARY)); - OPERATOR_MAP.put("!=", new Operator(OP_STRING_NONEQUAL, 5, OP_BINARY)); - OPERATOR_MAP.put("(", new Operator(OP_LPAREN, -1, OP_SPECIAL)); - OPERATOR_MAP.put(")", new Operator(OP_RPAREN, 6, OP_SPECIAL)); - } - - public void execute() - throws Exception { - boolean res = false; - CommandLine commandLine = getCommandLine(); - String commandName = commandLine.getCommandName(); - bracketted = (commandName != null && commandName.equals("[")); - args = commandLine.getArguments(); - try { - if (bracketted && args.length == 0) { - throw new SyntaxErrorException("missing ']'"); - } else if (bracketted && !args[args.length - 1].equals("]")) { - processAsOptions(args); - res = true; - } else { - lastArg = bracketted ? args.length - 2 : args.length - 1; - if (lastArg == -1) { - res = false; - } else { - Object obj = evaluate(); - if (pos <= lastArg) { - if (args[pos].equals(")")) { - throw new SyntaxErrorException("unmatched ')'"); - } else { - throw new AssertionError("I'm confused! pos = " + pos + - ", lastArg = " + lastArg + ", next arg is " + args[pos]); - } - } - if (obj instanceof Boolean) { - res = obj == Boolean.TRUE; - } else if (obj instanceof Long) { - res = ((Long) obj).longValue() != 0; - } else { - res = obj.toString().length() > 0; - } - } - } - if (!res) { - exit(1); - } - } catch (SyntaxErrorException ex) { - getError().getPrintWriter().println(ex.getMessage()); - exit(2); - } - } - - private Object evaluate() throws SyntaxErrorException { - evaluateExpression(false); - while (!operatorStack.isEmpty()) { - reduce(); - } - if (operandStack.size() != 1) { - throw new AssertionError("wrong nos operands left"); - } - return operandStack.pop(); - } - - private void evaluateExpression(boolean nested) throws SyntaxErrorException { - evaluatePrimary(nested); - while (pos <= lastArg) { - String tok = next(); - Operator op = OPERATOR_MAP.get(tok); - if (op == null) { - throw new SyntaxErrorException("expected an operator"); - } - switch(op.kind) { - case OP_UNARY: - throw new SyntaxErrorException("misplaced unary operator"); - case OP_BINARY: - evaluatePrimary(nested); - reduceAndPush(op, popOperand()); - break; - case OP_SPECIAL: - if (op.opNo == OP_LPAREN) { - throw new SyntaxErrorException("misplaced '('"); - } else if (op.opNo == OP_RPAREN) { - if (!nested) { - throw new SyntaxErrorException("misplaced ')'"); - } - back(); - return; - } - } - } - } - - private void evaluatePrimary(boolean nested) throws SyntaxErrorException { - String tok = next(); - Operator op = OPERATOR_MAP.get(tok); - if (op == null) { - pushOperand(tok); - } else { - switch (op.kind) { - case OP_UNARY: - operatorStack.push(op); - operandStack.push(next()); - break; - case OP_BINARY: - throw new SyntaxErrorException("misplaced binary operator"); - case OP_SPECIAL: - if (op.opNo == OP_LPAREN) { - operatorStack.push(op); // ... as a marker. - evaluateExpression(true); - if (!next().equals(")")) { - throw new SyntaxErrorException("missing ')'"); - } - while (operatorStack.peek() != op) { - reduce(); - } - if (operatorStack.pop() != op) { - throw new AssertionError("cannot find my marker!"); - } - } else { - throw new SyntaxErrorException("unmatched ')'"); - } - } - } - } - - private void reduceAndPush(Operator operator, Object operand) throws SyntaxErrorException { - while (!operatorStack.isEmpty() && operator.priority <= operatorStack.peek().priority) { - reduce(); - } - operatorStack.push(operator); - operandStack.push(operand); - } - - private void reduce() throws SyntaxErrorException { - Operator operator = operatorStack.pop(); - Object operand = null, operand2 = null; - if (operator.kind == OP_UNARY) { - operand = popOperand(); - } else if (operator.kind == OP_BINARY) { - operand2 = popOperand(); - operand = popOperand(); - } - switch (operator.opNo) { - case OP_EXISTS: - pushOperand(toFile(operand).exists()); - break; - case OP_DIRECTORY: - pushOperand(toFile(operand).isDirectory()); - break; - case OP_FILE: - pushOperand(toFile(operand).isFile()); - break; - case OP_NONEMPTY: - pushOperand(toFile(operand).length() > 0); - break; - case OP_READABLE: - pushOperand(toFile(operand).canRead()); - break; - case OP_WRITEABLE: - pushOperand(toFile(popOperand()).canWrite()); - break; - case OP_OLDER: - pushOperand(toFile(operand).lastModified() < toFile(operand2).lastModified()); - break; - case OP_NEWER: - pushOperand(toFile(operand).lastModified() > toFile(operand2).lastModified()); - break; - case OP_STRING_EMPTY: - pushOperand(toString().length() == 0); - break; - case OP_STRING_NONEMPTY: - pushOperand(toString(operand).length() > 0); - break; - case OP_STRING_LENGTH: - pushOperand(toString(operand).length()); - break; - case OP_EQ: - pushOperand(toNumber(operand) == toNumber(operand2)); - break; - case OP_NE: - pushOperand(toNumber(operand) != toNumber(operand2)); - break; - case OP_LT: - pushOperand(toNumber(operand) < toNumber(operand2)); - break; - case OP_LE: - pushOperand(toNumber(operand) <= toNumber(operand2)); - break; - case OP_GT: - pushOperand(toNumber(operand) > toNumber(operand2)); - break; - case OP_GE: - pushOperand(toNumber(operand) >= toNumber(operand2)); - break; - case OP_AND: - pushOperand(toBoolean(operand) & toBoolean(operand2)); - break; - case OP_OR: - pushOperand(toBoolean(operand) | toBoolean(operand2)); - break; - case OP_NOT: - pushOperand(!toBoolean(operand)); - break; - case OP_STRING_EQUALS: - pushOperand(toString(operand).equals(toString(operand2))); - break; - case OP_STRING_NONEQUAL: - pushOperand(!toString(operand).equals(toString(operand2))); - break; - default: - throw new AssertionError("bad operator"); - } - } - - private void processAsOptions(String[] args) throws SyntaxErrorException { - PrintWriter err = getError().getPrintWriter(); - for (String option : args) { - if (option.equals("--help")) { - err.println("Don't panic!"); - } else if (option.equals("--version")) { - err.println("JNode test 0.0"); - } else { - throw new SyntaxErrorException("unknown option '" + option + "'"); - } - } - } - - private void pushOperand(Object value) { - operandStack.push(value); - } - - private void pushOperand(boolean value) { - operandStack.push(value ? Boolean.TRUE : Boolean.FALSE); - } - - private void pushOperand(long value) { - operandStack.push(new Long(value)); - } - - private Object popOperand() throws SyntaxErrorException { - if (operandStack.isEmpty()) { - throw new SyntaxErrorException("missing LHS for operator"); - } - return operandStack.pop(); - } - - private long toNumber(Object obj) throws SyntaxErrorException { - if (obj instanceof Long) { - return ((Long) obj).longValue(); - } else if (obj instanceof String) { - try { - return Long.parseLong((String) obj); - } catch (NumberFormatException ex) { - throw new SyntaxErrorException( - "operand is not a number: '" + obj.toString() + "'"); - } - } else { - throw new SyntaxErrorException("subexpression is not an INTEGER"); - } - } - - private boolean toBoolean(Object obj) throws SyntaxErrorException { - if (obj instanceof Boolean) { - return obj == Boolean.TRUE; - } else if (obj instanceof String) { - return ((String) obj).length() > 0; - } else { - throw new SyntaxErrorException("operand is an INTEGER"); - } - } - - private String toString(Object obj) throws SyntaxErrorException { - if (obj instanceof String) { - return (String) obj; - } else { - throw new SyntaxErrorException("operand is not a STRING"); - } - } - - private File toFile(Object obj) throws SyntaxErrorException { - if (obj instanceof String) { - return new File((String) obj); - } else { - throw new SyntaxErrorException("operand is not a FILENAME"); - } - } - - private String next() { - if (pos > lastArg) { - return null; - } - return args[pos++]; - } - - private void back() throws SyntaxErrorException { - pos--; - } - - public static void main(String[] args) throws Exception { - // If you invoke it this way you cannot distinguish 'test' from '[' - new UnixTestCommand().execute(args); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-18 13:23:25
|
Revision: 4887 http://jnode.svn.sourceforge.net/jnode/?rev=4887&view=rev Author: crawley Date: 2009-01-18 13:23:15 +0000 (Sun, 18 Jan 2009) Log Message: ----------- First checkin of a test harness for testing JNode commands and scripts. (This entails moving most of Emu into the 'shell' project.) Modified Paths: -------------- trunk/shell/.classpath trunk/shell/build.xml trunk/shell/descriptors/org.jnode.test.shell.xml trunk/shell/src/test/org/jnode/test/shell/Cassowary.java Added Paths: ----------- trunk/shell/src/emu/ trunk/shell/src/emu/org/ trunk/shell/src/emu/org/jnode/ trunk/shell/src/emu/org/jnode/emu/ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java trunk/shell/src/emu/org/jnode/emu/Emu.java trunk/shell/src/emu/org/jnode/emu/EmuException.java trunk/shell/src/test/org/jnode/test/shell/command/ trunk/shell/src/test/org/jnode/test/shell/command/posix/ trunk/shell/src/test/org/jnode/test/shell/command/posix/TrueTest.xml trunk/shell/src/test/org/jnode/test/shell/harness/ trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/Test.java trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java Removed Paths: ------------- trunk/distr/src/emu/org/jnode/emu/DeviceManager.java trunk/distr/src/emu/org/jnode/emu/Emu.java trunk/distr/src/emu/org/jnode/emu/EmuException.java Deleted: trunk/distr/src/emu/org/jnode/emu/DeviceManager.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/DeviceManager.java 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/distr/src/emu/org/jnode/emu/DeviceManager.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -1,105 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.emu; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.apache.log4j.Logger; -import org.jnode.driver.AbstractDeviceManager; -import org.jnode.driver.Device; -import org.jnode.driver.DeviceFinder; -import org.jnode.driver.DeviceToDriverMapper; -import org.jnode.driver.DriverException; - -/** - * @author Levente S\u00e1ntha - */ -public class DeviceManager extends AbstractDeviceManager { - public static final Logger log = Logger.getLogger(DeviceManager.class); - - public static final DeviceManager INSTANCE = new DeviceManager(); - - private List<DeviceFinder> finders = new ArrayList<DeviceFinder>(); - - private List<DeviceToDriverMapper> mappers = new ArrayList<DeviceToDriverMapper>(); - - private DeviceManager() { - } - - public void removeAll() { - finders.clear(); - mappers.clear(); - - for (Device device : getDevices()) { - try { - unregister(device); - } catch (DriverException e) { - log.error("can't unregister " + device); - } - } - } - - public void add(DeviceFinder finder, DeviceToDriverMapper mapper) { - boolean doStart = false; - - if (!finders.contains(finder)) { - finders.add(finder); - doStart = true; - } - - if (!mappers.contains(mapper)) { - mappers.add(mapper); - doStart = true; - } - - if (doStart) { - start(); - } - } - - /** - * Start this manager - */ - public final void start() { - // Thread thread = new Thread() - // { - // public void run() - // { - log.debug("Loading extensions ..."); - loadExtensions(); - log.debug("Extensions loaded !"); - // } - // }; - // thread.start(); - - try { - // must be called before findDeviceDrivers - log.debug("findDevices ..."); - findDevices(); - - log.debug("findDeviceDrivers ..."); - findDeviceDrivers(); - - log.debug("StubDeviceManager initialized !"); - } catch (InterruptedException e) { - log.fatal("can't find devices", e); - } - } - - protected final void refreshFinders(List<DeviceFinder> finders) { - log.info("refreshFinders"); - finders.clear(); - finders.addAll(this.finders); - } - - protected final void refreshMappers(List<DeviceToDriverMapper> mappers) { - log.info("refreshMappers"); - mappers.clear(); - mappers.addAll(this.mappers); - - // Now sort them - Collections.sort(mappers, MapperComparator.INSTANCE); - } -} Deleted: trunk/distr/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/Emu.java 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/distr/src/emu/org/jnode/emu/Emu.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -1,228 +0,0 @@ -/* - * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.jnode.emu; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -import javax.naming.NamingException; - -import org.jnode.emu.naming.BasicNameSpace; -import org.jnode.emu.plugin.model.DummyExtensionPoint; -import org.jnode.naming.InitialNaming; -import org.jnode.nanoxml.XMLElement; -import org.jnode.shell.ShellManager; -import org.jnode.shell.alias.AliasManager; -import org.jnode.shell.alias.def.DefaultAliasManager; -import org.jnode.shell.def.DefaultShellManager; -import org.jnode.shell.help.HelpFactory; -import org.jnode.shell.help.def.DefaultHelpFactory; -import org.jnode.shell.syntax.DefaultSyntaxManager; -import org.jnode.shell.syntax.SyntaxBundle; -import org.jnode.shell.syntax.SyntaxManager; -import org.jnode.shell.syntax.SyntaxSpecAdapter; -import org.jnode.shell.syntax.SyntaxSpecLoader; -import org.jnode.shell.syntax.XMLSyntaxSpecAdapter; - -/** - * This class is the core of a light-weight JNode emulator that allows (some) JNode - * applications to be run using a classic JVM in the context of a JNode development sandbox. - * - * @author Levente S\u00e1ntha - * @author Stephen Crawley - */ -public abstract class Emu { - private static final String[] ALL_PROJECTS = new String[]{ - "core", "distr", "fs", "gui", "net", "shell", "sound", "textui" - }; - - private static final String[] PLUGIN_NAMES = new String[]{ - "org.jnode.shell.command", - "org.jnode.shell.command.driver.console", - "org.jnode.apps.editor", - "org.jnode.apps.edit", - "org.jnode.apps.console", - }; - - /** - * Initialize a minimal subset of JNode services to allow us to run JNode commands. - * - * @param root the notional JNode sandbox root directory or <code>null</code>. - * @throws EmuException - */ - public static void initEnv(File root) throws EmuException { - if (true) { - if (root == null) { - root = new File("").getAbsoluteFile(); - System.err.println("Assuming that the JNode root is '" + root + "'"); - } - InitialNaming.setNameSpace(new BasicNameSpace()); - - try { - InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); - AliasManager aliasMgr = - new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); - SyntaxManager syntaxMgr = - new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); - for (String pluginName : PLUGIN_NAMES) { - configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr); - } - System.setProperty("jnode.invoker", "thread"); - System.setProperty("jnode.interpreter", "redirecting"); - System.setProperty("jnode.debug", "true"); - InitialNaming.bind(AliasManager.NAME, aliasMgr); - InitialNaming.bind(ShellManager.NAME, new DefaultShellManager()); - InitialNaming.bind(SyntaxManager.NAME, syntaxMgr); - InitialNaming.bind(HelpFactory.NAME, new DefaultHelpFactory()); - } catch (NamingException ex) { - throw new EmuException("Problem setting up InitialNaming bindings", ex); - } - } - } - - /** - * Configure any command classes specified by a given plugin's descriptor - * - * @param root the root directory for the JNode sandbox. - * @param pluginName the plugin to be processed - * @param aliasMgr the alias manager to be populated - * @param syntaxMgr the syntax manager to be populated - * @throws EmuException - */ - private static void configurePluginCommands(File root, String pluginName, AliasManager aliasMgr, - SyntaxManager syntaxMgr) throws EmuException { - XMLElement pluginDescriptor = loadPluginDescriptor(root, pluginName); - extractAliases(pluginDescriptor, aliasMgr); - extractSyntaxBundles(pluginDescriptor, syntaxMgr); - } - - /** - * Populate the supplied syntax manager with syntax entries from a plugin descriptor. - * - * @param pluginDescriptor the plugin descriptor's root XML element - * @param syntaxMgr the syntax manager to be populated. - * @throws EmuException - */ - private static void extractSyntaxBundles(XMLElement pluginDescriptor, SyntaxManager syntaxMgr) - throws EmuException { - XMLElement syntaxesDescriptor = findExtension(pluginDescriptor, SyntaxManager.SYNTAXES_EP_NAME); - if (syntaxesDescriptor == null) { - return; - } - SyntaxSpecLoader loader = new SyntaxSpecLoader(); - for (XMLElement syntaxDescriptor : syntaxesDescriptor.getChildren()) { - if (!syntaxDescriptor.getName().equals("syntax")) { - continue; - } - SyntaxSpecAdapter adaptedElement = new XMLSyntaxSpecAdapter(syntaxDescriptor); - try { - SyntaxBundle bundle = loader.loadSyntax(adaptedElement); - if (bundle != null) { - syntaxMgr.add(bundle); - } - } catch (Exception ex) { - throw new EmuException("problem in syntax", ex); - } - } - } - - /** - * Populate the supplied alias manager with aliases from a plugin descriptor. - * - * @param pluginDescriptor the plugin descriptor's root XML element - * @param aliasMgr the alias manager to be populated. - * @throws EmuException - */ - private static void extractAliases(XMLElement pluginDescriptor, AliasManager aliasMgr) { - XMLElement aliasesDescriptor = findExtension(pluginDescriptor, AliasManager.ALIASES_EP_NAME); - if (aliasesDescriptor == null) { - return; - } - for (XMLElement aliasDescriptor : aliasesDescriptor.getChildren()) { - if (aliasDescriptor.getName().equals("alias")) { - String alias = aliasDescriptor.getStringAttribute("name"); - String className = aliasDescriptor.getStringAttribute("class"); - aliasMgr.add(alias, className); - } - } - } - - /** - * Locate the descriptor for a given extension point. - * - * @param pluginDescriptor the plugin descriptor - * @param epName the extension point's name - * @return - */ - private static XMLElement findExtension(XMLElement pluginDescriptor, String epName) { - for (XMLElement child : pluginDescriptor.getChildren()) { - if (child.getName().equals("extension") && - epName.equals(child.getStringAttribute("point"))) { - return child; - } - } - return null; - } - - /** - * Locate and load a plugin descriptor. We search the "descriptors" directory of - * each of the projects listed in ALL_PROJECTS - * - * @param root the notional root directory for the user's JNode sandbox. - * @param pluginName the name of the plugin we're trying to locate - * @return the loaded plugin descriptor or <code>null</code> - * @throws EmuException - */ - private static XMLElement loadPluginDescriptor(File root, String pluginName) - throws EmuException { - File file = null; - for (String projectName : ALL_PROJECTS) { - file = new File(new File(new File(root, projectName), "descriptors"), pluginName + ".xml"); - if (file.exists()) { - break; - } - } - if (!file.exists()) { - throw new EmuException("Cannot find plugin descriptor file for '" + - pluginName + "': " + file.getAbsolutePath()); - } - BufferedReader br = null; - try { - XMLElement elem = new XMLElement(); - br = new BufferedReader(new FileReader(file)); - elem.parseFromReader(br); - if (!elem.getName().equals("plugin")) { - throw new EmuException("File does not contain a 'plugin' descriptor: " + file); - } - return elem; - } catch (IOException ex) { - throw new EmuException("Problem reading / parsing plugin descriptor file " + file, ex); - } finally { - try { - br.close(); - } catch (IOException ex) { - // ignore - } - } - } -} Deleted: trunk/distr/src/emu/org/jnode/emu/EmuException.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/EmuException.java 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/distr/src/emu/org/jnode/emu/EmuException.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -1,12 +0,0 @@ -package org.jnode.emu; - -public class EmuException extends Exception { - - public EmuException(String message) { - super(message); - } - - public EmuException(String message, Throwable cause) { - super(message, cause); - } -} Modified: trunk/shell/.classpath =================================================================== --- trunk/shell/.classpath 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/shell/.classpath 2009-01-18 13:23:15 UTC (rev 4887) @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/shell"/> + <classpathentry kind="src" path="src/emu"/> <classpathentry kind="src" path="src/test"/> <classpathentry kind="src" path="/JNode-Core"/> <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> @@ -9,5 +10,6 @@ <classpathentry kind="lib" path="/JNode-Core/lib/ant-launcher.jar"/> <classpathentry exported="true" kind="lib" path="lib/bsh-2.0b5.jar"/> <classpathentry kind="lib" path="lib/rhino1.6r5-jsr223.jar"/> + <classpathentry kind="lib" path="/JNode-Builder/lib/nanoxml-2.2.3.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/shell/build.xml =================================================================== --- trunk/shell/build.xml 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/shell/build.xml 2009-01-18 13:23:15 UTC (rev 4887) @@ -28,6 +28,7 @@ <jnode.compile> <src path="${my-src.dir}/shell"/> <src path="${my-src.dir}/test"/> + <src path="${my-src.dir}/emu"/> <classpath refid="my-cp"/> </jnode.compile> </target> Modified: trunk/shell/descriptors/org.jnode.test.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.test.shell.xml 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/shell/descriptors/org.jnode.test.shell.xml 2009-01-18 13:23:15 UTC (rev 4887) @@ -20,9 +20,13 @@ <runtime> <library name="jnode-shell.jar"> <export name="org.jnode.test.shell.*"/> + <export name="org.jnode.test.shell.bjorne.*"/> + <export name="org.jnode.test.shell.harness.*"/> <export name="org.jnode.test.shell.help.*"/> + <export name="org.jnode.test.shell.proclet.*"/> + <export name="org.jnode.test.shell.io.*"/> + <export name="org.jnode.test.shell.proclet.*"/> <export name="org.jnode.test.shell.syntax.*"/> - <export name="org.jnode.test.shell.proclet.*"/> </library> </runtime> @@ -34,5 +38,6 @@ <extension point="org.jnode.security.permissions"> <permission class="java.lang.RuntimePermission" name="setIO"/> + <permission class="java.lang.RuntimePermission" name="exitVM"/> </extension> </plugin> Added: trunk/shell/src/emu/org/jnode/emu/DeviceManager.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/DeviceManager.java (rev 0) +++ trunk/shell/src/emu/org/jnode/emu/DeviceManager.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,105 @@ +/* + * $Id$ + */ +package org.jnode.emu; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.log4j.Logger; +import org.jnode.driver.AbstractDeviceManager; +import org.jnode.driver.Device; +import org.jnode.driver.DeviceFinder; +import org.jnode.driver.DeviceToDriverMapper; +import org.jnode.driver.DriverException; + +/** + * @author Levente S\u00e1ntha + */ +public class DeviceManager extends AbstractDeviceManager { + public static final Logger log = Logger.getLogger(DeviceManager.class); + + public static final DeviceManager INSTANCE = new DeviceManager(); + + private List<DeviceFinder> finders = new ArrayList<DeviceFinder>(); + + private List<DeviceToDriverMapper> mappers = new ArrayList<DeviceToDriverMapper>(); + + private DeviceManager() { + } + + public void removeAll() { + finders.clear(); + mappers.clear(); + + for (Device device : getDevices()) { + try { + unregister(device); + } catch (DriverException e) { + log.error("can't unregister " + device); + } + } + } + + public void add(DeviceFinder finder, DeviceToDriverMapper mapper) { + boolean doStart = false; + + if (!finders.contains(finder)) { + finders.add(finder); + doStart = true; + } + + if (!mappers.contains(mapper)) { + mappers.add(mapper); + doStart = true; + } + + if (doStart) { + start(); + } + } + + /** + * Start this manager + */ + public final void start() { + // Thread thread = new Thread() + // { + // public void run() + // { + log.debug("Loading extensions ..."); + loadExtensions(); + log.debug("Extensions loaded !"); + // } + // }; + // thread.start(); + + try { + // must be called before findDeviceDrivers + log.debug("findDevices ..."); + findDevices(); + + log.debug("findDeviceDrivers ..."); + findDeviceDrivers(); + + log.debug("StubDeviceManager initialized !"); + } catch (InterruptedException e) { + log.fatal("can't find devices", e); + } + } + + protected final void refreshFinders(List<DeviceFinder> finders) { + log.info("refreshFinders"); + finders.clear(); + finders.addAll(this.finders); + } + + protected final void refreshMappers(List<DeviceToDriverMapper> mappers) { + log.info("refreshMappers"); + mappers.clear(); + mappers.addAll(this.mappers); + + // Now sort them + Collections.sort(mappers, MapperComparator.INSTANCE); + } +} Added: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java (rev 0) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,232 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.emu; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import javax.naming.NamingException; + +import org.jnode.emu.naming.BasicNameSpace; +import org.jnode.emu.plugin.model.DummyExtensionPoint; +import org.jnode.naming.InitialNaming; +import org.jnode.nanoxml.XMLElement; +import org.jnode.shell.ShellManager; +import org.jnode.shell.alias.AliasManager; +import org.jnode.shell.alias.def.DefaultAliasManager; +import org.jnode.shell.def.DefaultShellManager; +import org.jnode.shell.help.HelpFactory; +import org.jnode.shell.help.def.DefaultHelpFactory; +import org.jnode.shell.syntax.DefaultSyntaxManager; +import org.jnode.shell.syntax.SyntaxBundle; +import org.jnode.shell.syntax.SyntaxManager; +import org.jnode.shell.syntax.SyntaxSpecAdapter; +import org.jnode.shell.syntax.SyntaxSpecLoader; +import org.jnode.shell.syntax.XMLSyntaxSpecAdapter; + +/** + * Emu is the core of a light-weight JNode emulator that allows (some) JNode + * applications to be run using a classic JVM in the context of a JNode development sandbox. + * <p> + * An Emu is also a large flightless bird ... which seems kind of appropriate. + * + * @author Levente S\u00e1ntha + * @author Stephen Crawley + */ +public abstract class Emu { + private static final String[] ALL_PROJECTS = new String[]{ + "core", "distr", "fs", "gui", "net", "shell", "sound", "textui" + }; + + // FIXME configuring a hard-coded list of command plugins is a bad idea. + private static final String[] PLUGIN_NAMES = new String[]{ + "org.jnode.shell.command", + "org.jnode.shell.command.posix", + "org.jnode.shell.command.driver.console", + "org.jnode.apps.editor", + "org.jnode.apps.edit", + "org.jnode.apps.console", + }; + + /** + * Initialize a minimal subset of JNode services to allow us to run JNode commands. + * + * @param root the notional JNode sandbox root directory or <code>null</code>. + * @throws EmuException + */ + public static void initEnv(File root) throws EmuException { + if (true) { + if (root == null) { + root = new File("").getAbsoluteFile(); + System.err.println("Assuming that the JNode root is '" + root + "'"); + } + InitialNaming.setNameSpace(new BasicNameSpace()); + + try { + InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); + AliasManager aliasMgr = + new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); + SyntaxManager syntaxMgr = + new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); + for (String pluginName : PLUGIN_NAMES) { + configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr); + } + System.setProperty("jnode.invoker", "thread"); + System.setProperty("jnode.interpreter", "redirecting"); + System.setProperty("jnode.debug", "true"); + InitialNaming.bind(AliasManager.NAME, aliasMgr); + InitialNaming.bind(ShellManager.NAME, new DefaultShellManager()); + InitialNaming.bind(SyntaxManager.NAME, syntaxMgr); + InitialNaming.bind(HelpFactory.NAME, new DefaultHelpFactory()); + } catch (NamingException ex) { + throw new EmuException("Problem setting up InitialNaming bindings", ex); + } + } + } + + /** + * Configure any command classes specified by a given plugin's descriptor + * + * @param root the root directory for the JNode sandbox. + * @param pluginName the plugin to be processed + * @param aliasMgr the alias manager to be populated + * @param syntaxMgr the syntax manager to be populated + * @throws EmuException + */ + private static void configurePluginCommands(File root, String pluginName, AliasManager aliasMgr, + SyntaxManager syntaxMgr) throws EmuException { + XMLElement pluginDescriptor = loadPluginDescriptor(root, pluginName); + extractAliases(pluginDescriptor, aliasMgr); + extractSyntaxBundles(pluginDescriptor, syntaxMgr); + } + + /** + * Populate the supplied syntax manager with syntax entries from a plugin descriptor. + * + * @param pluginDescriptor the plugin descriptor's root XML element + * @param syntaxMgr the syntax manager to be populated. + * @throws EmuException + */ + private static void extractSyntaxBundles(XMLElement pluginDescriptor, SyntaxManager syntaxMgr) + throws EmuException { + XMLElement syntaxesDescriptor = findExtension(pluginDescriptor, SyntaxManager.SYNTAXES_EP_NAME); + if (syntaxesDescriptor == null) { + return; + } + SyntaxSpecLoader loader = new SyntaxSpecLoader(); + for (XMLElement syntaxDescriptor : syntaxesDescriptor.getChildren()) { + if (!syntaxDescriptor.getName().equals("syntax")) { + continue; + } + SyntaxSpecAdapter adaptedElement = new XMLSyntaxSpecAdapter(syntaxDescriptor); + try { + SyntaxBundle bundle = loader.loadSyntax(adaptedElement); + if (bundle != null) { + syntaxMgr.add(bundle); + } + } catch (Exception ex) { + throw new EmuException("problem in syntax", ex); + } + } + } + + /** + * Populate the supplied alias manager with aliases from a plugin descriptor. + * + * @param pluginDescriptor the plugin descriptor's root XML element + * @param aliasMgr the alias manager to be populated. + * @throws EmuException + */ + private static void extractAliases(XMLElement pluginDescriptor, AliasManager aliasMgr) { + XMLElement aliasesDescriptor = findExtension(pluginDescriptor, AliasManager.ALIASES_EP_NAME); + if (aliasesDescriptor == null) { + return; + } + for (XMLElement aliasDescriptor : aliasesDescriptor.getChildren()) { + if (aliasDescriptor.getName().equals("alias")) { + String alias = aliasDescriptor.getStringAttribute("name"); + String className = aliasDescriptor.getStringAttribute("class"); + aliasMgr.add(alias, className); + } + } + } + + /** + * Locate the descriptor for a given extension point. + * + * @param pluginDescriptor the plugin descriptor + * @param epName the extension point's name + * @return + */ + private static XMLElement findExtension(XMLElement pluginDescriptor, String epName) { + for (XMLElement child : pluginDescriptor.getChildren()) { + if (child.getName().equals("extension") && + epName.equals(child.getStringAttribute("point"))) { + return child; + } + } + return null; + } + + /** + * Locate and load a plugin descriptor. We search the "descriptors" directory of + * each of the projects listed in ALL_PROJECTS + * + * @param root the notional root directory for the user's JNode sandbox. + * @param pluginName the name of the plugin we're trying to locate + * @return the loaded plugin descriptor or <code>null</code> + * @throws EmuException + */ + private static XMLElement loadPluginDescriptor(File root, String pluginName) + throws EmuException { + File file = null; + for (String projectName : ALL_PROJECTS) { + file = new File(new File(new File(root, projectName), "descriptors"), pluginName + ".xml"); + if (file.exists()) { + break; + } + } + if (!file.exists()) { + throw new EmuException("Cannot find plugin descriptor file for '" + + pluginName + "': " + file.getAbsolutePath()); + } + BufferedReader br = null; + try { + XMLElement elem = new XMLElement(); + br = new BufferedReader(new FileReader(file)); + elem.parseFromReader(br); + if (!elem.getName().equals("plugin")) { + throw new EmuException("File does not contain a 'plugin' descriptor: " + file); + } + return elem; + } catch (IOException ex) { + throw new EmuException("Problem reading / parsing plugin descriptor file " + file, ex); + } finally { + try { + br.close(); + } catch (IOException ex) { + // ignore + } + } + } +} Added: trunk/shell/src/emu/org/jnode/emu/EmuException.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/EmuException.java (rev 0) +++ trunk/shell/src/emu/org/jnode/emu/EmuException.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,12 @@ +package org.jnode.emu; + +public class EmuException extends Exception { + + public EmuException(String message) { + super(message); + } + + public EmuException(String message, Throwable cause) { + super(message, cause); + } +} Modified: trunk/shell/src/test/org/jnode/test/shell/Cassowary.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/Cassowary.java 2009-01-18 11:04:39 UTC (rev 4886) +++ trunk/shell/src/test/org/jnode/test/shell/Cassowary.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -34,9 +34,11 @@ import org.jnode.shell.help.def.DefaultHelpFactory; /** - * A Cassowary is another large Australian bird ... + * This class assembles a minimal set of JNode services to support unit + * testing some shell and syntax infrastructure. + * <p> + * A Cassowary is another large flightless bird ... like an Emu but different. * - * @author Levente S\u00e1ntha * @author cr...@jn... */ public class Cassowary { Added: trunk/shell/src/test/org/jnode/test/shell/command/posix/TrueTest.xml =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/command/posix/TrueTest.xml (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/command/posix/TrueTest.xml 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,6 @@ +<testSpec> +<title>Test 'true'</title> +<command>org.jnode.shell.command.posix.TrueCommand</command> +<runMode>AS_ALIAS</runMode> +<rc>0</rc> +</testSpec> \ No newline at end of file Added: trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,59 @@ +/** + * + */ +package org.jnode.test.shell.harness; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.lang.reflect.Method; + +/** + * This TestRunner runs a a class by calling its 'static void main(Sting[])' entry + * point. Note that classes that call System.exit(status) are problematic. + * + * @author cr...@jn... + */ +class ClassTestRunner implements TestRunnable { + + private ByteArrayOutputStream outBucket; + private ByteArrayOutputStream errBucket; + + private final TestSpecification spec; + private final TestHarness harness; + + public ClassTestRunner(TestSpecification spec, TestHarness harness) { + this.spec = spec; + this.harness = harness; + } + + @Override + public int run() throws Exception { + Class<?> commandClass = Class.forName(spec.getCommand()); + Method method = commandClass.getMethod("main", String[].class); + String[] args = spec.getArgs().toArray(new String[0]); + method.invoke(null, (Object) args); + return check() ? 0 : 1; + } + + private boolean check() { + // When a class is run this way we cannot capture the RC. + return + harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") && + harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); + } + + @Override + public void cleanup() { + } + + @Override + public void setup() { + System.setIn(new ByteArrayInputStream(spec.getInputContent().getBytes())); + outBucket = new ByteArrayOutputStream(); + errBucket = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBucket)); + System.setErr(new PrintStream(errBucket)); + } + +} \ No newline at end of file Added: trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,121 @@ +/** + * + */ +package org.jnode.test.shell.harness; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintStream; +import java.lang.reflect.Method; + +import org.jnode.shell.CommandInfo; +import org.jnode.shell.CommandInvoker; +import org.jnode.shell.CommandLine; +import org.jnode.shell.CommandShell; +import org.jnode.shell.ShellUtils; +import org.jnode.shell.ThreadCommandInvoker; +import org.jnode.shell.alias.AliasManager; +import org.jnode.shell.alias.NoSuchAliasException; + + +/** + * This TestRunner runs a a class by calling its 'static void main(Sting[])' entry + * point. Note that classes that call System.exit(status) are problematic. + * + * @author cr...@jn... + */ +class CommandTestRunner implements TestRunnable { + + private ByteArrayOutputStream outBucket; + private ByteArrayOutputStream errBucket; + + private final TestSpecification spec; + private final TestHarness harness; + + @SuppressWarnings("unused") + private final boolean usingEmu; + + private static boolean emuInitialized; + private static boolean emuAvailable; + private static CommandShell shell; + + public CommandTestRunner(TestSpecification spec, TestHarness harness) { + this.spec = spec; + this.harness = harness; + this.usingEmu = initEmu(harness.getRoot()); + } + + private static synchronized boolean initEmu(File root) { + if (!emuInitialized) { + // This is a bit of a hack. We don't want class loader dependencies + // on the Emu code because that won't work when we run on JNode. But + // we need to use Emu if we are running tests on the dev't platform. + // The following infers that we are running on the dev't platform if + // the 'Emu' class is not loadable. + try { + Class<?> cls = Class.forName("org.jnode.emu.Emu"); + Method initMethod = cls.getMethod("initEnv", File.class); + initMethod.invoke(null, root); + emuAvailable = true; + } catch (Throwable ex) { + // debug ... + ex.printStackTrace(System.err); + emuAvailable = false; + } + try { + if (emuAvailable) { + shell = new CommandShell(); + } else { + shell = (CommandShell) ShellUtils.getCurrentShell(); + } + } catch (Exception ex) { + // debug ... + ex.printStackTrace(System.err); + throw new RuntimeException(ex); + } + emuInitialized = true; + } + return emuAvailable; + } + + @Override + public int run() throws Exception { + String[] args = spec.getArgs().toArray(new String[0]); + AliasManager aliasMgr = ShellUtils.getAliasManager(); + CommandInvoker invoker = new ThreadCommandInvoker(shell); + CommandLine cmdLine = new CommandLine(spec.getCommand(), args); + CommandInfo cmdInfo; + try { + Class<?> cls = aliasMgr.getAliasClass(spec.getCommand()); + cmdInfo = new CommandInfo(cls, aliasMgr.isInternal(spec.getCommand())); + } catch (NoSuchAliasException ex) { + final ClassLoader cl = + Thread.currentThread().getContextClassLoader(); + cmdInfo = new CommandInfo(cl.loadClass(spec.getCommand()), false); + } + invoker.invoke(cmdLine, cmdInfo); + return check() ? 0 : 1; + } + + private boolean check() { + // When a class is run this way we cannot capture the RC. + return + harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") && + harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); + } + + @Override + public void cleanup() { + } + + @Override + public void setup() { + System.setIn(new ByteArrayInputStream(spec.getInputContent().getBytes())); + outBucket = new ByteArrayOutputStream(); + errBucket = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBucket)); + System.setErr(new PrintStream(errBucket)); + } + +} \ No newline at end of file Added: trunk/shell/src/test/org/jnode/test/shell/harness/Test.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/Test.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/Test.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,16 @@ +package org.jnode.test.shell.harness; + +public class Test { + + /** + * @param args + */ + public static void main(String[] args) { + if (args.length == 0) { + System.out.println("Hi mum"); + } else if (args[0].equals("System.exit")) { + System.exit(1); + } + } + +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,219 @@ +package org.jnode.test.shell.harness; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; + +import net.n3.nanoxml.XMLException; + +/** + * This is the entry point class for the command test harness. Its + * purpose is to run 'black box' tests on commands and the like. + * + * @author crawley@jnode + */ +public class TestHarness { + + private final String commandName = this.getClass().getCanonicalName(); + + String[] TESTS = new String[] { + "<testSpec>" + + "<title>Hi mum</title>" + + "<command>org.jnode.test.shell.harness.Test</command>" + + "<output>Hi mum\n</output>" + + "</testSpec>", +// "<testSpec>" + +// "<title>exit</title>" + +// "<command>org.jnode.test.shell.harness.Test</command>" + +// "<args><arg>System.exit</arg></args>" + +// "</testSpec>" + }; + + private final String[] args; + + private PrintWriter reportWriter; + private int testCount; + private int errorCount; + private int failureCount; + private TestSpecification spec = null; + private InputStream savedIn; + private PrintStream savedOut; + private PrintStream savedErr; + + private boolean verbose; + + public TestHarness(String[] args) { + this.args = args; + this.reportWriter = new PrintWriter(System.err); + } + + /** + * @param args + */ + public static void main(String[] args) throws Exception { + new TestHarness(args).run(); + } + + private void run() throws Exception { + if (args.length == 0) { + for (String test : TESTS) { + try { + InputStream is = new ByteArrayInputStream(test.getBytes()); + spec = new TestSpecification().load(is); + execute(spec); + } catch (Exception ex) { + diagnose(ex, "<built-in-tests>"); + } + } + } else if (args[0].equals("--package")) { + if (args.length != 2) { + usage(); + } + InputStream is = null; + try { + is = this.getClass().getResourceAsStream(args[1]); + spec = new TestSpecification().load(is); + execute(spec); + } catch (Exception ex) { + diagnose(ex, args[1]); + } + finally { + if (is != null) { + try { + is.close(); + } catch (IOException ex) { + // ignore + } + } + } + } else if (args[0].startsWith("-")) { + System.err.println("Unrecognized option '" + args[0] + "'"); + usage(); + return; + } else { + for (String arg : args) { + File file = new File(arg); + InputStream is = null; + try { + is = new FileInputStream(file); + spec = new TestSpecification().load(is); + execute(spec); + } catch (Exception ex) { + diagnose(ex, arg); + } + finally { + if (is != null) { + try { + is.close(); + } catch (IOException ex) { + // ignore + } + } + } + } + } + report("Ran " + testCount + " tests with " + errorCount + + " errors and " + failureCount + " failures"); + } + + private void usage() { + System.err.println(commandName + " // run tests from builtin specs"); + System.err.println(commandName + " --package <java-package> // run tests from specs on classpath"); + System.err.println(commandName + " <spec-file> ... // run tests from specs read from file system"); + } + + private void execute(TestSpecification spec) { + reportVerbose("Running test '" + spec.getTitle() + "'"); + testCount++; + try { + TestRunnable runner; + switch (spec.getRunMode()) { + case AS_CLASS: + runner = new ClassTestRunner(spec, this); + break; + case AS_ALIAS: + runner = new CommandTestRunner(spec, this); + break; + default: + reportVerbose("Run mode '" + spec.getRunMode() + "' not implemented"); + return; + } + try { + setup(); + runner.setup(); + errorCount += runner.run(); + } finally { + runner.cleanup(); + cleanup(); + } + } catch (Throwable ex) { + ex.printStackTrace(reportWriter); + failureCount++; + } + reportVerbose("Completed test '" + spec.getTitle() + "'"); + } + + private void diagnose(Exception ex, String fileName) throws Exception { + if (ex instanceof IOException) { + report("IO error while reading test specification: " + ex.getMessage()); + } else if (ex instanceof XMLException) { + String msg = ex.getMessage(); + if (msg.equals("Nested Exception")) { + msg = ((XMLException) ex).getException().getMessage(); + } + report("XML error in test specification '" + fileName + "' : " + msg); + } else if (ex instanceof TestSpecificationException) { + report("Invalid test specification '" + fileName + ": " + ex.getMessage()); + } else { + throw ex; + } + } + + /** + * Restore the system system streams + */ + private void cleanup() { + System.setIn(savedIn); + System.setOut(savedOut); + System.setErr(savedErr); + } + + /** + * Save the System streams so that they can be restored. + */ + private void setup() { + savedIn = System.in; + savedOut = System.out; + savedErr = System.err; + } + + public void report(String message) { + reportWriter.println(message); + reportWriter.flush(); + } + + public void reportVerbose(String message) { + if (verbose) { + report(message); + } + } + + public boolean expect(Object expected, Object actual, String desc) { + if (expected.equals(actual)) { + return true; + } + report("Incorrect test result for '" + desc + "' in test '" + spec.getTitle() + "'"); + report(" expected '" + expected + "': got '" + actual + "'"); + return false; + } + + public File getRoot() { + // FIXME ... this should be the workspace root. + return new File(".."); + } + +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnable.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,18 @@ +package org.jnode.test.shell.harness; + +/** + * This is the API implemented by the command test runners. We cannot + * use / extend Runnable because we need to propagate any exceptions + * in the {@link TestRunnable.run()} method. + * + * @author stephen + */ +public interface TestRunnable { + + public int run() throws Exception; + + public void setup(); + + public void cleanup(); + +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecification.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,157 @@ +package org.jnode.test.shell.harness; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.n3.nanoxml.IXMLElement; +import net.n3.nanoxml.IXMLParser; +import net.n3.nanoxml.StdXMLReader; +import net.n3.nanoxml.XMLParserFactory; + +/** + * This represents a command test specification for a command or script. + * + * @author crawley@jnode + */ +public class TestSpecification { + + public static enum RunMode { + AS_SCRIPT, + AS_CLASS, + AS_ALIAS + } + + private RunMode runMode; + private String command; + private List<String> args = new ArrayList<String>(); + private String inputContent; + private String outputContent; + private String errorContent; + private String title; + private int rc; + private Map<File, String> fileMap = new HashMap<File, String>(); + + private IXMLElement root; + + public TestSpecification() { + super(); + } + + public TestSpecification load(InputStream in) throws Exception { + StdXMLReader xr = new StdXMLReader(in); + IXMLParser parser = XMLParserFactory.createDefaultXMLParser(); + parser.setReader(xr); + root = (IXMLElement) parser.parse(); + if (!root.getName().equals("testSpec")) { + throw new TestSpecificationException( + "The root element should be 'testSpec' not '" + root.getName() + "'"); + } + runMode = RunMode.valueOf(extractElementValue("runMode", "AS_CLASS")); + title = extractElementValue("title"); + command = extractElementValue("command"); + inputContent = extractElementValue("input", ""); + outputContent = extractElementValue("output", ""); + errorContent = extractElementValue("error", ""); + try { + rc = Integer.parseInt(extractElementValue("error", "0").trim()); + } catch (NumberFormatException ex) { + throw new TestSpecificationException("'rc' is not an integer"); + } + IXMLElement elem = root.getFirstChildNamed("args"); + if (elem != null) { + for (Object obj : elem.getChildren()) { + if (obj instanceof IXMLElement) { + IXMLElement child = (IXMLElement) obj; + if (!child.getName().equals("arg")) { + throw new TestSpecificationException( + "Child elements of 'args' should be 'arg' not '" + root.getName() + "'"); + } + args.add(child.getContent()); + } + } + } + elem = root.getFirstChildNamed("files"); + if (elem != null) { + for (Object obj : elem.getChildren()) { + if (obj instanceof IXMLElement) { + IXMLElement child = (IXMLElement) obj; + if (!child.getName().equals("file")) { + throw new TestSpecificationException( + "Child elements of 'files' should be 'file' not '" + root.getName() + "'"); + } + String fileName = extractElementValue(child, "name"); + String content = extractElementValue(child, "content", ""); + fileMap.put(new File(fileName), content); + } + } + } + return this; + } + + private String extractElementValue(IXMLElement parent, String name) throws TestSpecificationException { + IXMLElement elem = parent.getFirstChildNamed(name); + if (elem == null) { + throw new TestSpecificationException( + "Element '" + name + "' not found in '" + parent.getName() + "'"); + } else { + return elem.getContent(); + } + } + + private String extractElementValue(IXMLElement parent, String name, String dflt) { + IXMLElement elem = parent.getFirstChildNamed(name); + return elem == null ? dflt : elem.getContent(); + } + + private String extractElementValue(String name) throws TestSpecificationException { + return extractElementValue(root, name); + } + + private String extractElementValue(String name, String dflt) { + return extractElementValue(root, name, dflt); + } + + public String getOutputContent() { + return outputContent; + } + + public String getErrorContent() { + return errorContent; + } + + public int getRc() { + return rc; + } + + public void addFile(File file, String content) { + fileMap.put(file, content); + } + + public Map<File, String> getFileMap() { + return fileMap; + } + + public RunMode getRunMode() { + return runMode; + } + + public String getCommand() { + return command; + } + + public List<String> getArgs() { + return args; + } + + public String getInputContent() { + return inputContent; + } + + public String getTitle() { + return title; + } +} Added: trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java (rev 0) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestSpecificationException.java 2009-01-18 13:23:15 UTC (rev 4887) @@ -0,0 +1,11 @@ +package org.jnode.test.shell.harness; + +public class TestSpecificationException extends Exception { + + private static final long serialVersionUID = -6276556804636413362L; + + public TestSpecificationException(String message) { + super(message); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-21 13:33:57
|
Revision: 4898 http://jnode.svn.sourceforge.net/jnode/?rev=4898&view=rev Author: crawley Date: 2009-01-21 13:33:53 +0000 (Wed, 21 Jan 2009) Log Message: ----------- Tidy up CommandShell's resource script execution + de-static'd Emu and friends. Modified Paths: -------------- trunk/distr/src/emu/org/jnode/emu/EditEmu.java trunk/distr/src/emu/org/jnode/emu/ShellEmu.java trunk/shell/src/emu/org/jnode/emu/Emu.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java Modified: trunk/distr/src/emu/org/jnode/emu/EditEmu.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/EditEmu.java 2009-01-21 13:32:57 UTC (rev 4897) +++ trunk/distr/src/emu/org/jnode/emu/EditEmu.java 2009-01-21 13:33:53 UTC (rev 4898) @@ -10,14 +10,21 @@ * @author Levente S\u00e1ntha */ public class EditEmu extends Emu { + + public EditEmu(File root) throws EmuException { + super(root); + } + public static void main(String[] argv) throws Exception { if (argv.length == 0 || argv[0].startsWith("-")) { System.err.println("Usage: editEmu <file> [<jnode-home>]"); return; } - initEnv(argv.length > 1 ? new File(argv[1]) : null); - + new EditEmu(argv.length > 1 ? new File(argv[1]) : null).run(new File(argv[0])); + } + + private void run(File file) throws Exception { SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager(); final TextScreenConsole console = cm.createConsole( null, @@ -26,7 +33,6 @@ ConsoleManager.CreateOptions.NO_LINE_EDITTING)); TextEditor te = new TextEditor(console); - File f = new File(argv[0]); - te.loadFile(f); + te.loadFile(file); } } Modified: trunk/distr/src/emu/org/jnode/emu/ShellEmu.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/ShellEmu.java 2009-01-21 13:32:57 UTC (rev 4897) +++ trunk/distr/src/emu/org/jnode/emu/ShellEmu.java 2009-01-21 13:33:53 UTC (rev 4898) @@ -11,13 +11,20 @@ * @author Levente S\u00e1ntha */ public class ShellEmu extends Emu { + + public ShellEmu(File root) throws EmuException { + super(root); + } public static void main(String[] argv) throws Exception { if (argv.length > 0 && argv[0].startsWith("-")) { System.err.println("Usage: shellemu [<jnode-home>]"); return; } - initEnv(argv.length > 0 ? new File(argv[0]) : null); + new ShellEmu(argv.length > 0 ? new File(argv[0]) : null).run(); + } + + private void run() throws Exception { TextScreenConsoleManager cm = new SwingTextScreenConsoleManager(); new Thread(new CommandShell(cm.createConsole( "Console 1", Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-21 13:32:57 UTC (rev 4897) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-01-21 13:33:53 UTC (rev 4898) @@ -59,7 +59,7 @@ }; // FIXME configuring a hard-coded list of command plugins is a bad idea. - private static final String[] PLUGIN_NAMES = new String[]{ + private static final String[] PLUGIN_NAMES = new String[] { "org.jnode.shell.command", "org.jnode.shell.command.posix", "org.jnode.shell.command.driver.console", @@ -69,38 +69,36 @@ }; /** - * Initialize a minimal subset of JNode services to allow us to run JNode commands. + * The constructor initializes a minimal subset of JNode services to allow us to run JNode commands. * * @param root the notional JNode sandbox root directory or <code>null</code>. * @throws EmuException */ - public static void initEnv(File root) throws EmuException { - if (true) { - if (root == null) { - root = new File("").getAbsoluteFile(); - System.err.println("Assuming that the JNode root is '" + root + "'"); - } - InitialNaming.setNameSpace(new BasicNameSpace()); + public Emu(File root) throws EmuException { + if (root == null) { + root = new File("").getAbsoluteFile(); + System.err.println("Assuming that the JNode root is '" + root + "'"); + } + InitialNaming.setNameSpace(new BasicNameSpace()); - try { - InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); - AliasManager aliasMgr = - new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); - SyntaxManager syntaxMgr = - new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); - for (String pluginName : PLUGIN_NAMES) { - configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr); - } - System.setProperty("jnode.invoker", "thread"); - System.setProperty("jnode.interpreter", "redirecting"); - System.setProperty("jnode.debug", "true"); - InitialNaming.bind(AliasManager.NAME, aliasMgr); - InitialNaming.bind(ShellManager.NAME, new DefaultShellManager()); - InitialNaming.bind(SyntaxManager.NAME, syntaxMgr); - InitialNaming.bind(HelpFactory.NAME, new DefaultHelpFactory()); - } catch (NamingException ex) { - throw new EmuException("Problem setting up InitialNaming bindings", ex); + try { + InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); + AliasManager aliasMgr = + new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); + SyntaxManager syntaxMgr = + new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); + for (String pluginName : PLUGIN_NAMES) { + configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr); } + System.setProperty("jnode.invoker", "thread"); + System.setProperty("jnode.interpreter", "redirecting"); + System.setProperty("jnode.debug", "true"); + InitialNaming.bind(AliasManager.NAME, aliasMgr); + InitialNaming.bind(ShellManager.NAME, new DefaultShellManager()); + InitialNaming.bind(SyntaxManager.NAME, syntaxMgr); + InitialNaming.bind(HelpFactory.NAME, new DefaultHelpFactory()); + } catch (NamingException ex) { + throw new EmuException("Problem setting up InitialNaming bindings", ex); } } @@ -113,7 +111,7 @@ * @param syntaxMgr the syntax manager to be populated * @throws EmuException */ - private static void configurePluginCommands(File root, String pluginName, AliasManager aliasMgr, + private void configurePluginCommands(File root, String pluginName, AliasManager aliasMgr, SyntaxManager syntaxMgr) throws EmuException { XMLElement pluginDescriptor = loadPluginDescriptor(root, pluginName); extractAliases(pluginDescriptor, aliasMgr); @@ -127,7 +125,7 @@ * @param syntaxMgr the syntax manager to be populated. * @throws EmuException */ - private static void extractSyntaxBundles(XMLElement pluginDescriptor, SyntaxManager syntaxMgr) + private void extractSyntaxBundles(XMLElement pluginDescriptor, SyntaxManager syntaxMgr) throws EmuException { XMLElement syntaxesDescriptor = findExtension(pluginDescriptor, SyntaxManager.SYNTAXES_EP_NAME); if (syntaxesDescriptor == null) { @@ -157,7 +155,7 @@ * @param aliasMgr the alias manager to be populated. * @throws EmuException */ - private static void extractAliases(XMLElement pluginDescriptor, AliasManager aliasMgr) { + private void extractAliases(XMLElement pluginDescriptor, AliasManager aliasMgr) { XMLElement aliasesDescriptor = findExtension(pluginDescriptor, AliasManager.ALIASES_EP_NAME); if (aliasesDescriptor == null) { return; @@ -178,7 +176,7 @@ * @param epName the extension point's name * @return */ - private static XMLElement findExtension(XMLElement pluginDescriptor, String epName) { + private XMLElement findExtension(XMLElement pluginDescriptor, String epName) { for (XMLElement child : pluginDescriptor.getChildren()) { if (child.getName().equals("extension") && epName.equals(child.getStringAttribute("point"))) { @@ -197,7 +195,7 @@ * @return the loaded plugin descriptor or <code>null</code> * @throws EmuException */ - private static XMLElement loadPluginDescriptor(File root, String pluginName) + private XMLElement loadPluginDescriptor(File root, String pluginName) throws EmuException { File file = null; for (String projectName : ALL_PROJECTS) { Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-21 13:32:57 UTC (rev 4897) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-21 13:33:53 UTC (rev 4898) @@ -267,31 +267,9 @@ // Here, we are running in the CommandShell (main) Thread // so, we can register ourself as the current shell // (it will also be the current shell for all children Thread) + + configureShell(); - // FIXME - At one point, the 'current shell' had something to do with - // dispatching keyboard input to the right application. Now this is - // handled by the console layer. Is 'current shell' a meaningful / - // useful concept anymore? - try { - ShellUtils.getShellManager().registerShell(this); - - ShellUtils.registerCommandInvoker(DefaultCommandInvoker.FACTORY); - ShellUtils.registerCommandInvoker(ThreadCommandInvoker.FACTORY); - ShellUtils.registerCommandInvoker(ProcletCommandInvoker.FACTORY); - ShellUtils.registerCommandInvoker(IsolateCommandInvoker.FACTORY); - ShellUtils.registerCommandInterpreter(DefaultInterpreter.FACTORY); - ShellUtils - .registerCommandInterpreter(RedirectingInterpreter.FACTORY); - } catch (NameNotFoundException e1) { - e1.printStackTrace(); - } - - // Configure the shell based on Syetsm properties. - setupFromProperties(); - - // Now become interactive - ownThread = Thread.currentThread(); - // Run commands from the JNode command line first final String cmdLine = System.getProperty(CMDLINE_PROPERTY_NAME, ""); final StringTokenizer tok = new StringTokenizer(cmdLine); @@ -320,7 +298,7 @@ try { if (jnode_ini.exists()) { runCommandFile(jnode_ini); - } else { + } else if (getClass().getResource(name) != null) { runCommandResource(name); } } catch (ShellException ex) { @@ -340,7 +318,7 @@ try { if (shell_ini.exists()) { runCommandFile(shell_ini); - } else { + } else if (getClass().getResource(name) != null) { runCommandResource(name); } } catch (ShellException ex) { @@ -374,6 +352,28 @@ } } + public void configureShell() { + try { + ShellUtils.getShellManager().registerShell(this); + + ShellUtils.registerCommandInvoker(DefaultCommandInvoker.FACTORY); + ShellUtils.registerCommandInvoker(ThreadCommandInvoker.FACTORY); + ShellUtils.registerCommandInvoker(ProcletCommandInvoker.FACTORY); + ShellUtils.registerCommandInvoker(IsolateCommandInvoker.FACTORY); + ShellUtils.registerCommandInterpreter(DefaultInterpreter.FACTORY); + ShellUtils + .registerCommandInterpreter(RedirectingInterpreter.FACTORY); + } catch (NameNotFoundException e1) { + e1.printStackTrace(); + } + + // Configure the shell based on System properties. + setupFromProperties(); + + // Now become interactive + ownThread = Thread.currentThread(); + } + private void setupFromProperties() { debugEnabled = Boolean.parseBoolean(System.getProperty( DEBUG_PROPERTY_NAME, DEBUG_DEFAULT)); @@ -819,8 +819,7 @@ boolean enabled = setHistoryEnabled(false); try { CommandInterpreter interpreter = createInterpreter(new FileReader(file)); - // FIXME throw ShellException if interpreter not found - return (interpreter == null) ? -1 : interpreter.interpret(this, file); + return interpreter.interpret(this, file); } catch (IOException ex) { throw new ShellException("Cannot open command file: " + ex.getMessage(), ex); } finally { @@ -835,15 +834,11 @@ // FIXME throw ShellException if resource or interpreter not found InputStream input = getClass().getResourceAsStream(resource); if (input == null) { - result = -1; // resource doesn't exist + throw new ShellException("Cannot find resource '" + resource + "'"); } else { CommandInterpreter interpreter = createInterpreter(new InputStreamReader(input)); - if (interpreter == null) { - result = -1; // no interpreter ! - } else { - Reader reader = new InputStreamReader(getClass().getResourceAsStream(resource)); - result = interpreter.interpret(this, reader); - } + Reader reader = new InputStreamReader(getClass().getResourceAsStream(resource)); + result = interpreter.interpret(this, reader); } return result; } finally { @@ -856,11 +851,13 @@ final BufferedReader br = new BufferedReader(reader); CommandInterpreter interpreter; String line = br.readLine(); - if (line == null) { - interpreter = null; // stream is empty - } else if (line.startsWith("#!")) { + if (line != null && line.startsWith("#!")) { String name = line.substring(2); interpreter = ShellUtils.createInterpreter(name); + if (interpreter == null) { + throw new ShellException("Cannot execute script: no '" + + name + "' interpreter is registered"); + } } else { interpreter = this.interpreter; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-21 14:11:59
|
Revision: 4901 http://jnode.svn.sourceforge.net/jnode/?rev=4901&view=rev Author: crawley Date: 2009-01-21 14:11:55 +0000 (Wed, 21 Jan 2009) Log Message: ----------- Tweaking a couple of @author tags Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java trunk/shell/src/shell/org/jnode/shell/io/NullInputStream.java Modified: trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2009-01-21 13:34:29 UTC (rev 4900) +++ trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2009-01-21 14:11:55 UTC (rev 4901) @@ -46,7 +46,7 @@ * * @author epr * @author Andreas H\u00e4nel - * @author Stephen Crawley + * @author cr...@jn... * @author Fabien DUMINY (fd...@jn...) */ public class CatCommand extends AbstractCommand { Modified: trunk/shell/src/shell/org/jnode/shell/io/NullInputStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/NullInputStream.java 2009-01-21 13:34:29 UTC (rev 4900) +++ trunk/shell/src/shell/org/jnode/shell/io/NullInputStream.java 2009-01-21 14:11:55 UTC (rev 4901) @@ -27,7 +27,7 @@ * A NullInputStream instance is the logical equivalent of "/dev/null". Calling * a read method returns -1 to indicate EOF. * - * @author Stephen Crawley + * @author cr...@jn... */ public class NullInputStream extends InputStream { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-24 02:22:13
|
Revision: 4904 http://jnode.svn.sourceforge.net/jnode/?rev=4904&view=rev Author: crawley Date: 2009-01-24 02:16:41 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Some incremental tidyups for the CommandShell and Shell APIs. Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/charvabsh/CharvaBsh.java trunk/shell/src/shell/org/jnode/shell/CommandLine.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java trunk/shell/src/shell/org/jnode/shell/Shell.java trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java Modified: trunk/distr/src/apps/org/jnode/apps/charvabsh/CharvaBsh.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/charvabsh/CharvaBsh.java 2009-01-24 01:56:00 UTC (rev 4903) +++ trunk/distr/src/apps/org/jnode/apps/charvabsh/CharvaBsh.java 2009-01-24 02:16:41 UTC (rev 4904) @@ -420,7 +420,7 @@ if (shell instanceof CommandShell) { CommandShell cs = (CommandShell) shell; try { - cs.invokeCommand(command); + cs.runCommand(command); } catch (ShellException ex) { System.err.println("Command invocation failed: " + ex.getMessage()); } Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-01-24 01:56:00 UTC (rev 4903) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-01-24 02:16:41 UTC (rev 4904) @@ -573,7 +573,7 @@ * @throws CommandSyntaxException if the chosen syntax doesn't match the command * line arguments. */ - public CommandInfo parseCommandLine(CommandShell shell) throws ShellException { + public CommandInfo parseCommandLine(Shell shell) throws ShellException { String cmd = (commandToken == null) ? "" : commandToken.text.trim(); if (cmd.equals("")) { throw new ShellFailureException("no command name"); @@ -595,8 +595,6 @@ bundle.parse(this, syntaxes); } return cmdInfo; - } catch (ClassNotFoundException ex) { - throw new ShellException("Command class not found", ex); } catch (InstantiationException ex) { throw new ShellException("Command class cannot be instantiated", ex); } catch (IllegalAccessException ex) { @@ -610,8 +608,8 @@ CommandInfo cmdClass; try { cmdClass = shell.getCommandInfo(cmd); - } catch (ClassNotFoundException ex) { - throw new CompletionException("Command class not found", ex); + } catch (ShellException ex) { + throw new CompletionException(ex.getMessage(), ex); } Command command; @@ -652,15 +650,11 @@ } } - public CommandInfo getCommandInfo(CommandShell shell) { + public CommandInfo getCommandInfo(CommandShell shell) throws ShellException { String cmd = (commandToken == null) ? "" : commandToken.text.trim(); if (cmd.equals("")) { return null; } - try { - return shell.getCommandInfo(cmd); - } catch (ClassNotFoundException ex) { - return null; - } + return shell.getCommandInfo(cmd); } } Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-24 01:56:00 UTC (rev 4903) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-24 02:16:41 UTC (rev 4904) @@ -280,7 +280,7 @@ if (e.startsWith(COMMAND_KEY)) { final String cmd = e.substring(COMMAND_KEY.length()); outPW.println(prompt() + cmd); - processCommand(cmd, false); + runCommand(cmd, false, this.interpreter); } } catch (Throwable ex) { errPW.println("Error while processing bootarg commands: " @@ -338,7 +338,7 @@ readingCommand = true; String line = readInputLine().trim(); if (line.length() > 0) { - processCommand(line, true); + runCommand(line, true, this.interpreter); } if (VmSystem.isShuttingDown()) { @@ -464,12 +464,8 @@ ((KeyboardReader) in).clearSoftEOF(); } } - - protected int processCommand(String cmdLineStr, boolean interactive) { - return processCommand(cmdLineStr, interactive, this.interpreter); - } - private int processCommand(String cmdLineStr, boolean interactive, + private int runCommand(String cmdLineStr, boolean interactive, CommandInterpreter interpreter) { if (interactive) { clearEof(); @@ -536,8 +532,8 @@ * @param command the command line. * @throws ShellException */ - public int invokeCommand(String command) throws ShellException { - return processCommand(command, false); + public int runCommand(String command) throws ShellException { + return runCommand(command, false, this.interpreter); } /** @@ -567,14 +563,20 @@ return this.invoker.invokeAsynchronous(cmdLine, cmdInfo); } - public CommandInfo getCommandInfo(String cmd) throws ClassNotFoundException { + public CommandInfo getCommandInfo(String cmd) throws ShellException { try { Class<?> cls = aliasMgr.getAliasClass(cmd); return new CommandInfo(cls, aliasMgr.isInternal(cmd)); + } catch (ClassNotFoundException ex) { + throw new ShellException("Cannot the load command class for alias '" + cmd + "'", ex); } catch (NoSuchAliasException ex) { - final ClassLoader cl = - Thread.currentThread().getContextClassLoader(); - return new CommandInfo(cl.loadClass(cmd), false); + try { + final ClassLoader cl = + Thread.currentThread().getContextClassLoader(); + return new CommandInfo(cl.loadClass(cmd), false); + } catch (ClassNotFoundException ex2) { + throw new ShellException("Cannot find an alias or load a command class for '" + cmd + "'", ex); + } } } Modified: trunk/shell/src/shell/org/jnode/shell/Shell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-01-24 01:56:00 UTC (rev 4903) +++ trunk/shell/src/shell/org/jnode/shell/Shell.java 2009-01-24 02:16:41 UTC (rev 4904) @@ -75,4 +75,14 @@ */ public int runCommandFile(File file) throws ShellException; + /** + * Resolve a command name to a CommandInfo object. + * + * @param commmandName this could be a command class name, an alias or some other + * supported by the shell. + * @return the resolved CommandInfo or <code>null</code>. + * @throws ShellException + */ + public CommandInfo getCommandInfo(String commmandName) throws ShellException; + } Modified: trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java 2009-01-24 01:56:00 UTC (rev 4903) +++ trunk/shell/src/shell/org/jnode/shell/command/HelpCommand.java 2009-01-24 02:16:41 UTC (rev 4904) @@ -29,6 +29,7 @@ import org.jnode.shell.CommandInfo; import org.jnode.shell.CommandLine; import org.jnode.shell.CommandShell; +import org.jnode.shell.ShellException; import org.jnode.shell.ShellUtils; import org.jnode.shell.alias.AliasManager; import org.jnode.shell.alias.NoSuchAliasException; @@ -58,8 +59,7 @@ } @Override - public void execute() throws NameNotFoundException, ClassNotFoundException, - HelpException, NoSuchAliasException { + public void execute() throws NameNotFoundException, ShellException, HelpException { // The above exceptions are either bugs or configuration errors and should be allowed // to propagate so that the shell can diagnose them appropriately. String alias; @@ -87,13 +87,8 @@ } catch (HelpException ex) { err.println("Error getting help for alias / class '" + alias + "': " + ex.getMessage()); throw ex; - } catch (ClassNotFoundException ex) { - try { - String className = shell.getAliasManager().getAliasClassName(alias); - err.println("Cannot load class '" + className + "' for alias '" + alias + "'"); - } catch (NoSuchAliasException ex2) { - err.println("'" + alias + "' is neither an alias or a loadable class name"); - } + } catch (ShellException ex) { + err.println(ex.getMessage()); throw ex; } catch (SecurityException ex) { err.println("Security exception while loading the class associated with alias '" + alias + "'"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-01-26 06:47:47
|
Revision: 4909 http://jnode.svn.sourceforge.net/jnode/?rev=4909&view=rev Author: crawley Date: 2009-01-26 06:47:42 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Explicitly exclude '.svn' directories to stop Eclipse warnings about duplicate resources. (This may be redundant if you are using an SVN plugin.) Modified Paths: -------------- trunk/builder/.classpath trunk/core/.classpath trunk/distr/.classpath trunk/fs/.classpath trunk/gui/.classpath trunk/net/.classpath trunk/shell/.classpath Modified: trunk/builder/.classpath =================================================================== --- trunk/builder/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/builder/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/builder"/> - <classpathentry kind="src" path="src/configure"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/builder"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/configure"/> <classpathentry kind="src" path="/JNode-Core"/> <classpathentry kind="src" path="/JNode-FS"/> <classpathentry kind="lib" path="/JNode-Core/lib/ant.jar"/> Modified: trunk/core/.classpath =================================================================== --- trunk/core/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/core/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,26 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/openjdk/vm"/> - <classpathentry kind="src" path="src/emu"/> - <classpathentry kind="src" path="src/endorsed/nanoxml"/> - <classpathentry excluding="**/*-template.java" kind="src" path="src/openjdk/sun"/> - <classpathentry kind="src" path="src/openjdk/org"/> - <classpathentry excluding="**/*-template.java" kind="src" path="src/openjdk/com"/> - <classpathentry kind="src" path="src/icedtea"/> - <classpathentry kind="src" path="src/classpath/gnu"/> - <classpathentry kind="src" path="src/openjdk/java"/> - <classpathentry kind="src" path="src/openjdk/javax"/> - <classpathentry kind="src" path="src/classpath/tools"/> - <classpathentry kind="src" path="src/classpath/java"/> - <classpathentry kind="src" path="src/classpath/javax"/> - <classpathentry kind="src" path="src/classpath/ext"/> - <classpathentry kind="src" path="src/classpath/vm"/> - <classpathentry kind="src" path="src/core"/> - <classpathentry kind="src" path="src/vmmagic"/> - <classpathentry kind="src" path="src/mmtk-vm"/> - <classpathentry kind="src" path="src/driver"/> - <classpathentry kind="src" path="src/test"/> - <classpathentry kind="src" path="src/template"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/vm"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/emu"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/endorsed/nanoxml"/> + <classpathentry excluding="**/*-template.java|**/.svn/**" kind="src" path="src/openjdk/sun"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/org"/> + <classpathentry excluding="**/*-template.java|**/.svn/**" kind="src" path="src/openjdk/com"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/icedtea"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/gnu"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/java"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/javax"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/tools"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/java"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/javax"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/ext"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/vm"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/core"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/vmmagic"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/mmtk-vm"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/template"/> <classpathentry kind="lib" path="lib/ant.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="lib/junit.jar"/> Modified: trunk/distr/.classpath =================================================================== --- trunk/distr/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/distr/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/install"/> - <classpathentry kind="src" path="src/emu"/> - <classpathentry kind="src" path="src/test"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/install"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/emu"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="src" path="src/apps"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/apps"/> <classpathentry kind="src" path="/JNode-GUI"/> <classpathentry kind="lib" path="lib/telnetd.jar"/> <classpathentry kind="lib" path="lib/jetty-6.1.5.jar"/> Modified: trunk/fs/.classpath =================================================================== --- trunk/fs/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/fs/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/fs"/> - <classpathentry kind="src" path="src/driver"/> - <classpathentry kind="src" path="src/test"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/fs"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> <classpathentry kind="src" path="/JNode-Core"/> <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> <classpathentry kind="src" path="/JNode-Shell"/> Modified: trunk/gui/.classpath =================================================================== --- trunk/gui/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/gui/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/awt"/> - <classpathentry kind="src" path="src/font"/> - <classpathentry kind="src" path="src/desktop"/> - <classpathentry kind="src" path="src/driver"/> - <classpathentry kind="src" path="src/test"/> - <classpathentry kind="src" path="src/thinlet"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/awt"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/font"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/desktop"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/thinlet"/> <classpathentry kind="src" path="/JNode-Core"/> <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> <classpathentry kind="src" path="/JNode-Shell"/> Modified: trunk/net/.classpath =================================================================== --- trunk/net/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/net/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/net"/> - <classpathentry kind="src" path="src/driver"/> - <classpathentry kind="src" path="src/test"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/net"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> <classpathentry kind="src" path="/JNode-Core"/> <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="lib/oncrpc.jar"/> Modified: trunk/shell/.classpath =================================================================== --- trunk/shell/.classpath 2009-01-25 01:04:36 UTC (rev 4908) +++ trunk/shell/.classpath 2009-01-26 06:47:42 UTC (rev 4909) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/shell"/> - <classpathentry kind="src" path="src/emu"/> - <classpathentry kind="src" path="src/test"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/shell"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/emu"/> + <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> <classpathentry kind="src" path="/JNode-Core"/> <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="/JNode-Core/lib/junit.jar"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-01-31 09:52:57
|
Revision: 4932 http://jnode.svn.sourceforge.net/jnode/?rev=4932&view=rev Author: lsantha Date: 2009-01-31 09:52:51 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Fixed code style. Modified Paths: -------------- trunk/core/src/test/org/jtestserver/tests/TestVMware.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNode.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNodeRecord.java trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafRecord.java trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java trunk/shell/src/test/org/jnode/test/shell/harness/TextContent.java Modified: trunk/core/src/test/org/jtestserver/tests/TestVMware.java =================================================================== --- trunk/core/src/test/org/jtestserver/tests/TestVMware.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/core/src/test/org/jtestserver/tests/TestVMware.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -28,7 +28,6 @@ import org.jtestserver.client.process.vmware.VMware; import org.jtestserver.client.process.vmware.VMwareConfig; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; public class TestVMware extends TestVmManager { @@ -36,12 +35,12 @@ public void setUp() throws IOException { Config config = new CustomConfigReader(ConfigReader.VMWARE_TYPE).readConfig(); VMwareConfig vmwareConfig = (VMwareConfig) config.getVMConfig(); - + vmManager = new VMware(vmwareConfig); - vmName = vmwareConfig.getVmName(); + vmName = vmwareConfig.getVmName(); } - - @Test(expected = IOException.class) + + @Test(expected = IOException.class) public void testGetRunningVMsWithWrongAuthentification() throws IOException { CustomConfigReader reader = new CustomConfigReader(ConfigReader.VMWARE_TYPE) { @Override @@ -49,14 +48,14 @@ throws IOException { vmProperties.put(VMwareConfig.USERNAME, "anObviouslyWrongLogin"); vmProperties.put(VMwareConfig.PASSWORD, "ThisIsNotAValidPassword"); - + return super.createVMConfig(vmProperties, vm); } }; - + Config config = reader.readConfig(); VMwareConfig vmwareConfig = (VMwareConfig) config.getVMConfig(); - + VMware vmware = new VMware(vmwareConfig); vmware.getRunningVMs(); } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -16,16 +16,19 @@ import org.jnode.fs.hfsplus.tree.IndexRecord; import org.jnode.fs.hfsplus.tree.LeafRecord; import org.jnode.fs.hfsplus.tree.NodeDescriptor; -import org.jnode.fs.hfsplus.tree.NodeRecord; import org.jnode.util.ByteBufferUtils; public class Catalog { - + private final Logger log = Logger.getLogger(getClass()); private HfsPlusFileSystem fs; - /** B-Tree node descriptor */ + /** + * B-Tree node descriptor + */ private NodeDescriptor btnd; - /** B-Tree Header record */ + /** + * B-Tree Header record + */ private BTHeaderRecord bthr; /** */ private int catalogHeaderNodeOffset; @@ -34,9 +37,8 @@ /** * Create Catalog based on meta-data that exist on the file system. - * + * * @param fs HFS+ file system that contains catalog informations. - * * @throws IOException */ public Catalog(final HfsPlusFileSystem fs) throws IOException { @@ -46,27 +48,27 @@ ExtentDescriptor firstExtent = sb.getCatalogFile().getExtents()[0]; catalogHeaderNodeOffset = firstExtent.getStartBlock() * sb.getBlockSize(); if (firstExtent.getStartBlock() != 0 && firstExtent.getBlockCount() != 0) { - buffer = ByteBuffer.allocate(NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH - + BTHeaderRecord.BT_HEADER_RECORD_LENGTH); + buffer = ByteBuffer.allocate(NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH + + BTHeaderRecord.BT_HEADER_RECORD_LENGTH); fs.getApi().read(catalogHeaderNodeOffset, buffer); buffer.rewind(); byte[] data = ByteBufferUtils.toArray(buffer); btnd = new NodeDescriptor(data, 0); bthr = new BTHeaderRecord(data, NodeDescriptor.BT_NODE_DESCRIPTOR_LENGTH); - + } } - + /** * Create new Catalog - * + * * @param params */ public Catalog(HFSPlusParams params) { log.debug("Create B-Tree catalog file.\n"); - + int nodeSize = params.getCatalogNodeSize(); - + int bufferLength = 0; btnd = new NodeDescriptor(); btnd.setKind(HfsPlusConstants.BT_HEADER_NODE); @@ -108,7 +110,7 @@ offset = offset + ck.getKeyLength() + CatalogFolder.CATALOG_FOLDER_SIZE; CatalogKey tck = new CatalogKey(CatalogNodeId.HFSPLUS_ROOT_CNID, name); CatalogThread ct = new CatalogThread(HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, - CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); + CatalogNodeId.HFSPLUS_ROOT_CNID, new HFSUnicodeString("")); record = new LeafRecord(tck, ct.getBytes()); rootNode.addNodeRecord(1, record, offset); buffer = ByteBuffer.allocate(bufferLength + bthr.getNodeSize()); @@ -118,9 +120,8 @@ buffer.put(rootNode.getBytes()); buffer.rewind(); } - + /** - * * @param parentID * @return * @throws IOException @@ -136,7 +137,7 @@ byte[] data = ByteBufferUtils.toArray(nodeData); CatalogNode node = new CatalogNode(data, nodeSize); while (node.isIndexNode()) { - IndexRecord record = (IndexRecord)node.find(parentID); + IndexRecord record = (IndexRecord) node.find(parentID); currentOffset = catalogHeaderNodeOffset + (record.getIndex() * nodeSize); nodeData = ByteBuffer.allocate(nodeSize); fs.getApi().read(currentOffset, nodeData); @@ -144,20 +145,18 @@ data = ByteBufferUtils.toArray(nodeData); node = new CatalogNode(data, nodeSize); } - + if (node.isLeafNode()) { - lr = (LeafRecord)node.find(parentID); + lr = (LeafRecord) node.find(parentID); } return lr; } /** * Find leaf records corresponding to parentID. The search begin at the root node of the tree. - * + * * @param parentID Parent node id - * * @return Array of LeafRecord - * * @throws IOException */ public final LeafRecord[] getRecords(final CatalogNodeId parentID) @@ -166,14 +165,12 @@ } /** - * Find leaf records corresponding to parentID. The search begin at the node correspding + * Find leaf records corresponding to parentID. The search begin at the node correspding * to the index passed as parameter. - * - * @param parentID Parent node id + * + * @param parentID Parent node id * @param nodeNumber Index of node where the search begin. - * * @return Array of LeafRecord - * * @throws IOException */ public final LeafRecord[] getRecords(final CatalogNodeId parentID, final int nodeNumber) @@ -185,7 +182,7 @@ fs.getApi().read(catalogHeaderNodeOffset + (currentNodeNumber * nodeSize), nodeData); CatalogNode node = new CatalogNode(nodeData.array(), nodeSize); if (node.isIndexNode()) { - IndexRecord[] records = (IndexRecord[])node.findChilds(parentID); + IndexRecord[] records = (IndexRecord[]) node.findChilds(parentID); List<LeafRecord> lfList = new LinkedList<LeafRecord>(); for (IndexRecord rec : records) { LeafRecord[] lfr = getRecords(parentID, rec.getIndex()); @@ -195,7 +192,7 @@ } return lfList.toArray(new LeafRecord[lfList.size()]); } else if (node.isLeafNode()) { - return (LeafRecord[])node.findAll(parentID); + return (LeafRecord[]) node.findAll(parentID); } else { return null; } @@ -207,7 +204,6 @@ } /** - * * @param parentID * @param nodeName * @return @@ -223,7 +219,7 @@ int currentOffset = 0; CatalogKey cKey = new CatalogKey(parentID, nodeName); while (node.isIndexNode()) { - IndexRecord record = (IndexRecord)node.find(cKey); + IndexRecord record = (IndexRecord) node.find(cKey); currentNodeNumber = record.getIndex(); currentOffset = catalogHeaderNodeOffset + record.getIndex() * nodeSize; nodeData = ByteBuffer.allocate(nodeSize); @@ -232,7 +228,7 @@ } LeafRecord lr = null; if (node.isLeafNode()) { - lr = (LeafRecord)node.find(parentID); + lr = (LeafRecord) node.find(parentID); } return lr; } @@ -244,9 +240,9 @@ public final BTHeaderRecord getBTHeaderRecord() { return bthr; } - + public ByteBuffer getBytes() { return buffer; } - + } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNode.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNode.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -30,7 +30,7 @@ int recordSize = offset2 - offset; NodeRecord record = null; Key key = new CatalogKey(datas, offset); - if(isIndexNode()){ + if (isIndexNode()) { record = new IndexRecord(key, datas, offset); } else { record = new LeafRecord(key, datas, offset, recordSize); @@ -39,7 +39,6 @@ } /** - * * @param parentId * @return */ @@ -57,7 +56,6 @@ } /** - * * @param key * @return */ @@ -66,7 +64,7 @@ for (int index = 0; index < this.getNodeDescriptor().getNumRecords(); index++) { NodeRecord record = this.getNodeRecord(index); if ((record.getKey().compareTo(key) <= 0) - && (record.getKey().compareTo(largestMatchingRecord.getKey()) > 0)) { + && (record.getKey().compareTo(largestMatchingRecord.getKey()) > 0)) { largestMatchingRecord = record; } } @@ -74,7 +72,6 @@ } /** - * * @param parentId * @return */ @@ -86,7 +83,7 @@ NodeRecord record = this.getNodeRecord(index); CatalogKey key = (CatalogKey) record.getKey(); if (key.getParentId().getId() < parentId.getId() - && (largestMatchingKey == null || key.compareTo(largestMatchingKey) > 0)) { + && (largestMatchingKey == null || key.compareTo(largestMatchingKey) > 0)) { largestMatchingKey = key; largestMatchingRecord = record; } else if (key.getParentId().getId() == parentId.getId()) { @@ -101,7 +98,6 @@ } /** - * * @param parentId * @return */ Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNode.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNode.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -4,7 +4,7 @@ import org.jnode.util.BigEndian; public abstract class AbstractNode implements Node { - + protected byte[] datas; protected int size; @@ -12,15 +12,15 @@ public NodeDescriptor getNodeDescriptor() { return new NodeDescriptor(datas, 0); } - - public boolean isIndexNode(){ + + public boolean isIndexNode() { return this.getNodeDescriptor().getKind() == HfsPlusConstants.BT_INDEX_NODE; } - - public boolean isLeafNode(){ + + public boolean isLeafNode() { return this.getNodeDescriptor().getKind() == HfsPlusConstants.BT_LEAF_NODE; } - + @Override public int getRecordOffset(int index) { return BigEndian.getInt16(datas, size - ((index + 1) * 2)); @@ -28,14 +28,14 @@ @Override public abstract NodeRecord getNodeRecord(int index); - + @Override public void addNodeRecord(int index, NodeRecord record, int offset) { BigEndian.setInt16(datas, size - ((index + 1) * 2), offset); System.arraycopy(record.getBytes(), 0, datas, offset, record.getSize()); } - - public byte[] getBytes(){ + + public byte[] getBytes() { return datas; } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNodeRecord.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNodeRecord.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractNodeRecord.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -1,21 +1,21 @@ package org.jnode.fs.hfsplus.tree; public abstract class AbstractNodeRecord implements NodeRecord { - + protected Key key = null; protected byte[] recordData = null; - + public Key getKey() { return key; } - + public byte[] getData() { return recordData; } - - public int getSize(){ + + public int getSize() { return key.getKeyLength() + recordData.length; } - + public abstract byte[] getBytes(); } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafRecord.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafRecord.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafRecord.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -3,13 +3,13 @@ import org.jnode.util.BigEndian; public class LeafRecord extends AbstractNodeRecord { - - public LeafRecord(final Key key, final byte[] recordData){ + + public LeafRecord(final Key key, final byte[] recordData) { this.key = key; this.recordData = new byte[recordData.length]; - System.arraycopy(recordData,0, this.recordData, 0, recordData.length); + System.arraycopy(recordData, 0, this.recordData, 0, recordData.length); } - + public LeafRecord(final Key key, final byte[] nodeData, final int offset, final int recordDataSize) { this.key = key; this.recordData = new byte[recordDataSize]; @@ -27,9 +27,9 @@ System.arraycopy(data, key.getKeyLength(), this.recordData, 0, this.recordData.length); return data; } - + public final String toString() { return "Type : " + getType() + "\nKey : " + getKey().toString() + "\n"; } - + } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -28,17 +28,17 @@ /** * This TestRunner runs a a class by calling its 'static void main(Sting[])' entry * point. Note that classes that call System.exit(status) are problematic. - * + * * @author cr...@jn... */ class ClassTestRunner implements TestRunnable { private ByteArrayOutputStream outBucket; private ByteArrayOutputStream errBucket; - + private final TestSpecification spec; private final TestHarness harness; - + public ClassTestRunner(TestSpecification spec, TestHarness harness) { this.spec = spec; this.harness = harness; @@ -55,11 +55,11 @@ private boolean check() { // When a class is run this way we cannot capture the RC. - return + return harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") & - harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); + harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); } - + @Override public void cleanup() { } @@ -72,5 +72,5 @@ System.setOut(new PrintStream(outBucket)); System.setErr(new PrintStream(errBucket)); } - -} \ No newline at end of file + +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -30,15 +30,15 @@ /** * This TestRunner runs a class by calling its 'static void main(String[])' entry * point. Note that classes that call System.exit(status) are problematic. - * + * * @author cr...@jn... */ class CommandTestRunner extends JNodeTestRunnerBase implements TestRunnable { private ByteArrayOutputStream outBucket; private ByteArrayOutputStream errBucket; - - + + public CommandTestRunner(TestSpecification spec, TestHarness harness) { super(spec, harness); } @@ -56,12 +56,12 @@ } private boolean check(int rc) { - return + return harness.expect(rc, spec.getRc(), "return code") & - harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") & - harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); + harness.expect(outBucket.toString(), spec.getOutputContent(), "output content") & + harness.expect(errBucket.toString(), spec.getErrorContent(), "err content"); } - + @Override public void cleanup() { } @@ -74,5 +74,5 @@ System.setOut(new PrintStream(outBucket)); System.setErr(new PrintStream(errBucket)); } - -} \ No newline at end of file + +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/PluginSpecification.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -22,16 +22,16 @@ /** * This class holds a simple specification for a plugin required by a test or test set. - * + * * @author crawley@jnode */ public class PluginSpecification { private final String pluginId; private final String pluginVersion; private final String pseudoPluginClassName; - + public PluginSpecification(String pluginId, String pluginVersion, - String pseudoPluginClassName) { + String pseudoPluginClassName) { super(); this.pluginId = pluginId; this.pluginVersion = pluginVersion; @@ -47,13 +47,13 @@ } /** - * This method returns the classname of a 'pseudo plugin' class that can perform + * This method returns the classname of a 'pseudo plugin' class that can perform * minimal plugin specific initialization when a plugin is 'required' in * a context where Plugin loading is not possible. - * + * * @return the class name. */ public String getClassName() { return pseudoPluginClassName; } -} \ No newline at end of file +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -71,4 +71,4 @@ super.cleanup(); } -} \ No newline at end of file +} Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestCommandShell.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -35,20 +35,20 @@ import org.jnode.shell.io.NullOutputStream; /** - * This class extends CommandShell to modify the shell's stream resolution mechanism. - * The modified resolveStream resolves in/out/err to streams that are supplied in the - * constructor. - * + * This class extends CommandShell to modify the shell's stream resolution mechanism. + * The modified resolveStream resolves in/out/err to streams that are supplied in the + * constructor. + * * @author cr...@jn... */ public class TestCommandShell extends CommandShell { - + private final CommandInput cin; private final CommandOutput cout; private final CommandOutput cerr; - public TestCommandShell(InputStream in, PrintStream out, PrintStream err) - throws ShellException { + public TestCommandShell(InputStream in, PrintStream out, PrintStream err) + throws ShellException { super(); this.cin = new CommandInput(in); this.cout = new CommandOutput(out); Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -32,18 +32,18 @@ /** * This is the entry point class for the command test harness. Its * purpose is to run 'black box' tests on commands and the like. - * + * * @author crawley@jnode */ public class TestHarness { // TODO - if someone feels motivated, they could replace the error // reporting with something that generates (say) XML that can be // processed by a fancy error report generator. - + private final String commandName = this.getClass().getCanonicalName(); private final String[] args; - + private PrintWriter reportWriter; private int testCount; private int failureCount; @@ -78,7 +78,7 @@ if (args.length == 0) { usage(); return; - } + } for (int i = 0; i < args.length && args[i].startsWith("-"); i++) { String optName = args[i]; if (optName.equals("-r") || optName.equals("--resource") || optName.equals("--resources")) { @@ -93,9 +93,9 @@ } root = new File(args[i]); } else { - System.err.println("Unrecognized option '" + optName + "'"); - usage(); - return; + System.err.println("Unrecognized option '" + optName + "'"); + usage(); + return; } firstArg = i + 1; } @@ -123,8 +123,7 @@ execute(specs); } catch (Exception ex) { diagnose(ex, arg); - } - finally { + } finally { if (is != null) { try { is.close(); @@ -134,10 +133,10 @@ } } } - report("Ran " + testCount + " tests with " + failureCount + - " test failures and " + exceptionCount + " errors (exceptions)"); + report("Ran " + testCount + " tests with " + failureCount + + " test failures and " + exceptionCount + " errors (exceptions)"); } - + private void usage() { System.err.println(commandName + " [ <opt> ...] <spec-file> ... "); System.err.println("where <opt> is one of: "); @@ -145,7 +144,7 @@ System.err.println(" --sandbox | -s <dir-name> specifies the dev't sandbox root directory"); System.err.println(" --resource | -r looks for <spec-file> as a resource on the CLASSPATH"); } - + private void execute(TestSetSpecification specs) { for (TestSpecification spec : specs.getSpecs()) { execute(spec); @@ -226,7 +225,7 @@ reportWriter.println(message); reportWriter.flush(); } - + public void reportVerbose(String message) { if (verbose) { report(message); Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TextContent.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TextContent.java 2009-01-31 09:43:18 UTC (rev 4931) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TextContent.java 2009-01-31 09:52:51 UTC (rev 4932) @@ -4,7 +4,7 @@ private final String rawText; private final boolean trim; private final String processedText; - + public TextContent(String rawText, boolean trim) { super(); this.rawText = rawText; @@ -19,7 +19,7 @@ public boolean isTrim() { return trim; } - + @Override public String toString() { return processedText; @@ -38,8 +38,8 @@ * <li>Count the number of leading spaces on the (now) first line. * <li>Remove this number of leading spaces from all lines. * <li>Make sure that the last line has a final newline. - * </ol> - * + * </ol> + * * @param text * @return */ @@ -62,7 +62,7 @@ int count; int len = tmp.length(); for (count = 0; count < len && tmp.charAt(count) == ' '; count++) { - /**/ + /**/ } if (count > 0) { StringBuilder sb = new StringBuilder(len); @@ -70,18 +70,18 @@ for (int i = 0; i < len; i++) { char ch = tmp.charAt(i); switch (ch) { - case ' ': - if (pos++ >= count) { - sb.append(' '); - } - break; - case '\n': - sb.append('\n'); - pos = 0; - break; - default: - pos = count + 1; - sb.append(ch); + case ' ': + if (pos++ >= count) { + sb.append(' '); + } + break; + case '\n': + sb.append('\n'); + pos = 0; + break; + default: + pos = count + 1; + sb.append(ch); } } tmp = sb.toString(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-01 23:22:02
|
Revision: 4967 http://jnode.svn.sourceforge.net/jnode/?rev=4967&view=rev Author: lsantha Date: 2009-02-01 22:13:30 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Fixed code style. Modified Paths: -------------- trunk/core/src/core/org/jnode/util/BigEndian.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java Modified: trunk/core/src/core/org/jnode/util/BigEndian.java =================================================================== --- trunk/core/src/core/org/jnode/util/BigEndian.java 2009-02-01 22:03:50 UTC (rev 4966) +++ trunk/core/src/core/org/jnode/util/BigEndian.java 2009-02-01 22:13:30 UTC (rev 4967) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.util; @@ -248,16 +248,16 @@ final int v0 = data[offset + 1] & 0xFF; return (char) ((v1 << 8) | v0); } - + /** * Set char as byte in the given byte array at the given offset. - * + * * @param dst * @param offset * @param value */ public static void setChar(byte[] dst, int offset, char value) { - dst[offset + 1] = (byte)(value & 0xFF); - dst[offset + 0] = (byte)((value >>> 8) & 0xFF); + dst[offset + 1] = (byte) (value & 0xFF); + dst[offset + 0] = (byte) ((value >>> 8) & 0xFF); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2009-02-01 22:03:50 UTC (rev 4966) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2009-02-01 22:13:30 UTC (rev 4967) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus; import java.io.IOException; @@ -30,7 +30,6 @@ import org.apache.log4j.Logger; import org.jnode.fs.FSEntry; import org.jnode.fs.ReadOnlyFileSystemException; -import org.jnode.fs.hfsplus.catalog.Catalog; import org.jnode.fs.hfsplus.catalog.CatalogFolder; import org.jnode.fs.hfsplus.catalog.CatalogKey; import org.jnode.fs.hfsplus.catalog.CatalogNodeId; @@ -63,21 +62,21 @@ throw new ReadOnlyFileSystemException(); } Superblock volumeHeader = ((HfsPlusFileSystem) getFileSystem()) - .getVolumeHeader(); + .getVolumeHeader(); Calendar now = Calendar.getInstance(); now.setTime(new Date()); int macDate = (int) HFSUtils - .getDate(now.getTimeInMillis() / 1000, true); + .getDate(now.getTimeInMillis() / 1000, true); HFSUnicodeString dirName = new HFSUnicodeString(name); CatalogThread thread = new CatalogThread( - HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, this.folder - .getFolderId(), dirName); + HfsPlusConstants.RECORD_TYPE_FOLDER_THREAD, this.folder + .getFolderId(), dirName); CatalogFolder newFolder = new CatalogFolder(); newFolder - .setFolderId(new CatalogNodeId(volumeHeader.getNextCatalogId())); + .setFolderId(new CatalogNodeId(volumeHeader.getNextCatalogId())); newFolder.setCreateDate(macDate); newFolder.setContentModDate(macDate); newFolder.setAttrModDate(macDate); @@ -90,8 +89,8 @@ log.debug("New record folder :\n" + folderRecord.toString()); HFSPlusEntry newEntry = new HFSPlusEntry( - (HfsPlusFileSystem) getFileSystem(), null, this, name, - folderRecord); + (HfsPlusFileSystem) getFileSystem(), null, this, name, + folderRecord); volumeHeader.setFolderCount(volumeHeader.getFolderCount() + 1); log.debug("New volume header :\n" + volumeHeader.toString()); @@ -113,21 +112,21 @@ @Override protected final FSEntryTable readEntries() throws IOException { List<FSEntry> pathList = new LinkedList<FSEntry>(); - HfsPlusFileSystem fs = (HfsPlusFileSystem)getFileSystem(); - if(fs.getVolumeHeader().getFolderCount() > 0) { - LeafRecord[] records = fs.getCatalog().getRecords(folder.getFolderId()); - for (LeafRecord rec : records) { - if (rec.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER - || rec.getType() == HfsPlusConstants.RECORD_TYPE_FILE) { - String name = ((CatalogKey) rec.getKey()).getNodeName() + HfsPlusFileSystem fs = (HfsPlusFileSystem) getFileSystem(); + if (fs.getVolumeHeader().getFolderCount() > 0) { + LeafRecord[] records = fs.getCatalog().getRecords(folder.getFolderId()); + for (LeafRecord rec : records) { + if (rec.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER + || rec.getType() == HfsPlusConstants.RECORD_TYPE_FILE) { + String name = ((CatalogKey) rec.getKey()).getNodeName() .getUnicodeString(); - HFSPlusEntry e = new HFSPlusEntry( - (HfsPlusFileSystem) getFileSystem(), null, this, name, - rec); - pathList.add(e); - } + HFSPlusEntry e = new HFSPlusEntry( + (HfsPlusFileSystem) getFileSystem(), null, this, name, + rec); + pathList.add(e); } } + } return new FSEntryTable(((HfsPlusFileSystem) getFileSystem()), pathList); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-14 05:22:32
|
Revision: 5021 http://jnode.svn.sourceforge.net/jnode/?rev=5021&view=rev Author: crawley Date: 2009-02-14 05:22:25 +0000 (Sat, 14 Feb 2009) Log Message: ----------- Implemented a 'printenv' command to print the environment variables. (Currently does nothing useful, but some day you will be able to set environment variables using the bjorne interpreter, etc.) Modified Paths: -------------- trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java trunk/shell/descriptors/org.jnode.shell.command.xml trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java Added Paths: ----------- trunk/core/src/classpath/vm/gnu/java/security/action/GetEnvAction.java trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java Added: trunk/core/src/classpath/vm/gnu/java/security/action/GetEnvAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/GetEnvAction.java (rev 0) +++ trunk/core/src/classpath/vm/gnu/java/security/action/GetEnvAction.java 2009-02-14 05:22:25 UTC (rev 5021) @@ -0,0 +1,41 @@ +/* + * $Id: GetPropertiesAction.java 4973 2009-02-02 07:52:47Z lsantha $ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package gnu.java.security.action; + +import java.security.PrivilegedAction; +import java.util.Map; +import java.util.Properties; + + +/** + * Utility class for getting the map containing the environment variables in a privileged action. + * + * @author cr...@jn... + */ +public class GetEnvAction implements PrivilegedAction<Map<String, String>> { + + /** + * @see java.security.PrivilegedAction#run() + */ + public Map<String, String> run() { + return System.getenv(); + } +} Modified: trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java 2009-02-13 07:58:01 UTC (rev 5020) +++ trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java 2009-02-14 05:22:25 UTC (rev 5021) @@ -21,9 +21,11 @@ package gnu.java.security.action; import java.security.PrivilegedAction; +import java.util.Map; import java.util.Properties; + /** * Utility class for getting all system properties in a privileged action. * @@ -37,4 +39,4 @@ public Properties run() { return System.getProperties(); } -} +} \ No newline at end of file Modified: trunk/shell/descriptors/org.jnode.shell.command.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.xml 2009-02-13 07:58:01 UTC (rev 5020) +++ trunk/shell/descriptors/org.jnode.shell.command.xml 2009-02-14 05:22:25 UTC (rev 5021) @@ -42,6 +42,7 @@ <alias name="namespace" class="org.jnode.shell.command.NamespaceCommand"/> <alias name="onheap" class="org.jnode.shell.command.OnHeapCommand"/> <alias name="page" class="org.jnode.shell.command.PageCommand"/> + <alias name="printenv" class="org.jnode.shell.command.PrintEnvCommand"/> <alias name="run" class="org.jnode.shell.command.RunCommand"/> <alias name="set" class="org.jnode.shell.command.SetCommand"/> <alias name="sleep" class="org.jnode.shell.command.SleepCommand"/> @@ -250,6 +251,7 @@ <empty description="Filter standard input a page (screen) at a time"/> <argument argLabel="file" description="Output the file a page (screen) at a time"/> </syntax> + <syntax alias="env" description="Print the environment variables"/> <syntax alias="run" description="Run a command file"> <argument argLabel="file"/> </syntax> Modified: trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java 2009-02-13 07:58:01 UTC (rev 5020) +++ trunk/shell/src/shell/org/jnode/shell/command/EnvCommand.java 2009-02-14 05:22:25 UTC (rev 5021) @@ -34,6 +34,7 @@ * @author epr */ public class EnvCommand extends AbstractCommand { + // FIXME ... this class and the corresponding alias are incorrectly named public EnvCommand() { super("Print the system properties"); Added: trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java 2009-02-14 05:22:25 UTC (rev 5021) @@ -0,0 +1,60 @@ +/* + * $Id: EnvCommand.java 4977 2009-02-02 09:09:41Z lsantha $ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command; + +import gnu.java.security.action.GetEnvAction; + +import java.io.PrintWriter; +import java.security.AccessController; +import java.util.Map; +import java.util.TreeMap; + +import org.jnode.shell.AbstractCommand; + +/** + * This command prints the current environment variables. A regular JNode command + * cannot set environment variables because the Java APIs do not allow this. Environment + * variable setting is accomplished by the shell / interpreter and builtin commands, it at all. + * + * @author cr...@jn... + */ +public class PrintEnvCommand extends AbstractCommand { + + public PrintEnvCommand() { + super("Print the current environment variables"); + } + + public static void main(String[] args) throws Exception { + new PrintEnvCommand().execute(args); + } + + /** + * Execute this command + */ + public void execute() throws Exception { + final Map<String, String> env = (Map<String, String>) AccessController.doPrivileged(new GetEnvAction()); + final TreeMap<String, String> sortedEnv = new TreeMap<String, String>(env); + final PrintWriter out = getOutput().getPrintWriter(); + for (Map.Entry<String, String> entry : sortedEnv.entrySet()) { + out.println(entry.getKey() + '=' + entry.getValue()); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-15 05:39:36
|
Revision: 5026 http://jnode.svn.sourceforge.net/jnode/?rev=5026&view=rev Author: crawley Date: 2009-02-15 05:39:30 +0000 (Sun, 15 Feb 2009) Log Message: ----------- Changes to core infrastructure to allow 'procletization' of the System properties and environment. System.getenv() et al are wired up, but System.getProperties() et al are not. Also implemented in shell, the proclet-mode invoker and the Bjorne interpreter (via the 'export' built-in). Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/IOContext.java trunk/core/src/core/org/jnode/vm/VmIOContext.java trunk/core/src/core/org/jnode/vm/VmSystem.java trunk/core/src/openjdk/svm/java/lang/ProcessEnvironment.java trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java trunk/shell/src/shell/org/jnode/shell/CommandRunner.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java trunk/shell/src/shell/org/jnode/shell/ShellManager.java trunk/shell/src/shell/org/jnode/shell/ShellUtils.java trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java trunk/shell/src/shell/org/jnode/shell/def/DefaultShellManager.java trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java Added Paths: ----------- trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java Modified: trunk/core/src/core/org/jnode/vm/IOContext.java =================================================================== --- trunk/core/src/core/org/jnode/vm/IOContext.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/core/src/core/org/jnode/vm/IOContext.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -22,57 +22,24 @@ import java.io.InputStream; import java.io.PrintStream; +import java.util.Map; +import java.util.Properties; /** - * This interface provides the hooks for implementing special semantics for System.in, System.out - * and System.err. Specifically, it is used to implement 'proclet' mode where the stream objects - * are proxies for context specific streams. + * This interface provides the hooks for implementing special semantics for + * System.in, System.out and System.err. Specifically, it is used to implement + * 'proclet' mode where the stream objects are proxies for context specific + * streams. It also supports 'proclet' mode contextualization of the System + * properties ({@link System#getProperties()}) and environment ({@link System#getenv()}). * * @author Levente S\u00e1ntha * @author cr...@jn... */ public interface IOContext { + + // FIXME ... the name of this interface is misleading. /** - * This hook is used to set the 'global' version of System.in; e.g. the one used - * when there is no active proclet context. - * - * @param in the new global System.in - */ - void setGlobalInStream(InputStream in); - - /** - * This hook is used to get the 'global' version of System.in. - */ - InputStream getGlobalInStream(); - - /** - * This hook is used to set the 'global' version of System.out; e.g. the one used - * when there is no active proclet context. - * - * @param out the new global System.out - */ - void setGlobalOutStream(PrintStream out); - - /** - * This hook is used to get the 'global' version of System.out. - */ - PrintStream getGlobalOutStream(); - - /** - * This hook is used to set the 'global' version of System.err; e.g. the one used - * when there is no active proclet context. - * - * @param err the new global System.err - */ - void setGlobalErrStream(PrintStream err); - - /** - * This hook is used to get the 'global' version of System.err. - */ - PrintStream getGlobalErrStream(); - - /** * This hook is used when "setting" System.in; i.e. via System.setIn(in). * * @param in the application supplied value for System.in @@ -107,8 +74,31 @@ * This hook is used to get the 'real' stream underlying System.err in the current context. */ PrintStream getRealSystemErr(); + + /** + * The hook is used to get the current context's 'system properties' + */ + Properties getProperties(); + + /** + * The hook is used to set the current context's 'system properties' + */ + void setProperties(Properties props); + + /** + * The hook is used to get the current context's environment; e.g. containing exported + * shell variables. + */ + Map<String, String> getEnv(); + + /** + * The hook is used to get the current context's environment. + */ + void setEnv(Map<String, String> env); void enterContext(); void exitContext(); + + } Modified: trunk/core/src/core/org/jnode/vm/VmIOContext.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmIOContext.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/core/src/core/org/jnode/vm/VmIOContext.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -22,40 +22,29 @@ import java.io.InputStream; import java.io.PrintStream; +import java.util.Map; +import java.util.Properties; /** + * This is the implementation of the IOContext API that is be used when + * 'proclet' mode is not enabled. It also provides static methods for + * getting and setting the 'global' versions of the Stream state, and + * the System properties and environment. (The 'global' state is used + * in 'proclet' mode when the current thread is not part of a 'proclet'.) + * * @author Levente S\u00e1ntha * @author cr...@jn... */ public class VmIOContext implements IOContext { + // FIXME ... restrict visibility (if possible) and add Java security + // access controls. + private static InputStream globalInStream; private static PrintStream globalOutStream; private static PrintStream globalErrStream; + private static Properties globalSysProps; + private static Map<String, String> globalEnv; - public void setGlobalInStream(InputStream in) { - globalInStream = in; - } - - public void setGlobalOutStream(PrintStream out) { - globalOutStream = out; - } - - public PrintStream getGlobalOutStream() { - return globalOutStream; - } - - public void setGlobalErrStream(PrintStream err) { - globalErrStream = err; - } - - public PrintStream getGlobalErrStream() { - return globalErrStream; - } - - public InputStream getGlobalInStream() { - return globalInStream; - } - public void setSystemIn(InputStream in) { globalInStream = in; VmSystem.setStaticField(System.class, "in", in); @@ -90,4 +79,100 @@ public PrintStream getRealSystemOut() { return System.out; } + + public Map<String, String> getEnv() { + return globalEnv; + } + + public Properties getProperties() { + return globalSysProps; + } + + public void setEnv(Map<String, String> env) { + globalEnv = env; + } + + public void setProperties(Properties props) { + globalSysProps = props; + } + + /** + * Set the 'global' view of {@link System#in}. + * @param in the new input stream. + */ + public static void setGlobalInStream(InputStream in) { + globalInStream = in; + } + + /** + * Set the 'global' view of {@link System#out}. + * @param in the new output stream. + */ + public static void setGlobalOutStream(PrintStream out) { + globalOutStream = out; + } + + /** + * Get the 'global' view of {@link System#out}. + * @return the 'global' output stream. + */ + public static PrintStream getGlobalOutStream() { + return globalOutStream; + } + + /** + * Set the 'global' view of {@link System#err}. + * @param in the new error stream. + */ + public static void setGlobalErrStream(PrintStream err) { + globalErrStream = err; + } + + /** + * Get the 'global' view of {@link System#err}. + * @return the 'global' error stream. + */ + public static PrintStream getGlobalErrStream() { + return globalErrStream; + } + + /** + * Get the 'global' view of {@link System#in}. + * @return the 'global' input stream. + */ + public static InputStream getGlobalInStream() { + return globalInStream; + } + + /** + * Set the 'global' view of the environment returned by {@link System#getenv()}. + * @param env the new 'global' environment. + */ + public static void setGlobalEnv(Map<String, String> env) { + globalEnv = env; + } + + /** + * Set the 'global' view of the Properties returned by {@link System#getProperties()}. + * @param env the new 'global' properties. + */ + public static void setGlobalProperties(Properties props) { + globalSysProps = props; + } + + /** + * Get the 'global' view of the environment returned by {@link System#getenv()}. + * @return the current 'global' environment. + */ + public static Map<String, String> getGlobalEnv() { + return globalEnv; + } + + /** + * Get the 'global' view of the Properties returned by {@link System#getProperties()}. + * @return the current 'global' Properties. + */ + public static Properties getGlobalProperties() { + return globalSysProps; + } } Modified: trunk/core/src/core/org/jnode/vm/VmSystem.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmSystem.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/core/src/core/org/jnode/vm/VmSystem.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -171,11 +171,11 @@ final ConsoleAppender infoApp = new ConsoleAppender(new PatternLayout(LAYOUT)); root.addAppender(infoApp); - initOpenJDKSpeciffics(); + initOpenJDKSpecifics(); } } - private static void initOpenJDKSpeciffics() { + private static void initOpenJDKSpecifics() { //todo this will be moved to java.lang.System during openjdk integration sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess() { public sun.reflect.ConstantPool getConstantPool(Class klass) { @@ -199,6 +199,9 @@ throw new UnsupportedOperationException(); } }); + + // Trigger initialization of the global environment variables. + System.getenv(); } static boolean isInitialized() { @@ -221,14 +224,13 @@ if (bootOut == null) { bootOut = sout; bootOutStream = new PrintStream(bootOut, true); - IOContext ioContext = getIOContext(); - ioContext.setGlobalOutStream(bootOutStream); - ioContext.setGlobalErrStream(bootOutStream); + VmIOContext.setGlobalOutStream(bootOutStream); + VmIOContext.setGlobalErrStream(bootOutStream); return bootOutStream; } else if (VmIsolate.isRoot()) { return bootOutStream; } else { - return VmIsolate.currentIsolate().getIOContext().getGlobalOutStream(); + return VmIOContext.getGlobalOutStream(); } } @@ -1125,7 +1127,7 @@ * @return the global 'err' stream. */ public static PrintStream getGlobalErrStream() { - return getIOContext().getGlobalErrStream(); + return VmIOContext.getGlobalErrStream(); } /** @@ -1134,7 +1136,7 @@ * @return the global 'in' stream. */ public static InputStream getGlobalInStream() { - return getIOContext().getGlobalInStream(); + return VmIOContext.getGlobalInStream(); } /** @@ -1143,7 +1145,7 @@ * @return the global 'out' stream. */ public static PrintStream getGlobalOutStream() { - return getIOContext().getGlobalOutStream(); + return VmIOContext.getGlobalOutStream(); } /** Modified: trunk/core/src/openjdk/svm/java/lang/ProcessEnvironment.java =================================================================== --- trunk/core/src/openjdk/svm/java/lang/ProcessEnvironment.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/core/src/openjdk/svm/java/lang/ProcessEnvironment.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -57,9 +57,16 @@ import java.io.*; import java.util.*; +import org.jnode.vm.VmIOContext; +import org.jnode.vm.VmSystem; + final class ProcessEnvironment { + // FIXME ... this class needs some work for JNode, Redo / remove the + // code that populates the map from the 'C environment' and maybe even + // get rid of StringEnvironment and replace it with a simple HashMap. + private static final HashMap<Variable,Value> theEnvironment; private static final Map<String,String> theUnmodifiableEnvironment; static final int MIN_NAME_LENGTH = 0; @@ -78,16 +85,18 @@ theUnmodifiableEnvironment = Collections.unmodifiableMap (new StringEnvironment(theEnvironment)); + + VmIOContext.setGlobalEnv(theUnmodifiableEnvironment); } /* Only for use by System.getenv(String) */ static String getenv(String name) { - return theUnmodifiableEnvironment.get(name); + return VmSystem.getIOContext().getEnv().get(name); } /* Only for use by System.getenv() */ static Map<String,String> getenv() { - return theUnmodifiableEnvironment; + return VmSystem.getIOContext().getEnv(); } /* Only for use by ProcessBuilder.environment() */ Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -27,6 +27,8 @@ import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Map; +import java.util.Properties; import org.jnode.driver.input.KeyboardEvent; import org.jnode.driver.input.KeyboardListener; @@ -46,7 +48,7 @@ * @author Martin Husted Hartvig (ha...@jn...) * @author cr...@jn... */ -public abstract class AsyncCommandInvoker implements CommandInvoker, +public abstract class AsyncCommandInvoker implements SimpleCommandInvoker, KeyboardListener { CommandShell commandShell; @@ -92,9 +94,15 @@ CommandRunner cr = setup(cmdLine, cmdInfo); return forkIt(cmdLine, cmdInfo, cr); } - - private CommandRunner setup(CommandLine cmdLine, CommandInfo cmdInfo) + + protected CommandRunner setup(CommandLine cmdLine, CommandInfo cmdInfo) throws ShellException { + return setup(cmdLine, cmdInfo, null, null); + } + + protected CommandRunner setup(CommandLine cmdLine, CommandInfo cmdInfo, + Properties sysProps, Map<String, String> env) + throws ShellException { Method method; CommandRunner cr = null; @@ -112,7 +120,7 @@ throw new ShellInvocationException("Problem while creating command instance", ex); } if (command != null) { - cr = new CommandRunner(this, cmdInfo, cmdLine, resolvedIOs); + cr = new CommandRunner(this, cmdInfo, cmdLine, resolvedIOs, sysProps, env); } else { try { method = cmdInfo.getCommandClass().getMethod(MAIN_METHOD, MAIN_ARG_TYPES); @@ -132,7 +140,7 @@ method.setAccessible(true); cr = new CommandRunner( this, cmdInfo, cmdInfo.getCommandClass(), method, - new Object[] {cmdLine.getArguments()}, resolvedIOs); + new Object[] {cmdLine.getArguments()}, resolvedIOs, sysProps, env); } catch (NoSuchMethodException e) { // continue; } @@ -147,7 +155,7 @@ return cr; } - private int runIt(CommandLine cmdLine, CommandInfo cmdInfo, CommandRunner cr) + protected int runIt(CommandLine cmdLine, CommandInfo cmdInfo, CommandRunner cr) throws ShellInvocationException { try { if (cmdInfo.isInternal()) { @@ -178,7 +186,7 @@ } } - private CommandThread forkIt(CommandLine cmdLine, CommandInfo cmdInfo, + protected CommandThread forkIt(CommandLine cmdLine, CommandInfo cmdInfo, CommandRunner cr) throws ShellInvocationException { if (cmdInfo.isInternal()) { throw new ShellFailureException("unexpected internal command"); Modified: trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -20,36 +20,35 @@ package org.jnode.shell; -/* - * User: Sam Reid Date: Dec 20, 2003 Time: 1:18:31 AM Copyright (c) Dec 20, 2003 - * by Sam Reid - */ +import java.util.Map; +import java.util.Properties; /** - * This is the common API for the various mechanisms for running 'commands'. - * - * @author Sam Reid + * This 'advanced' invoker API adds methods for invoking commands with + * different system properties or environment variables to the parent. + * * @author cr...@jn... */ -public interface CommandInvoker { +public interface CommandInvoker extends SimpleCommandInvoker { - public interface Factory { - CommandInvoker create(CommandShell shell); - - String getName(); - } - /** * Run a command synchronously, passing back the resulting return code. * * @param commandLine this provides the command name (alias), the command * arguments and (where relevant) the command's i/o stream context. * @param cmdInfo a CommandInfo descriptor for the command to be run. + * @param sysProps a Properties object containing the command's system + * properties. If this parameter is {@code null}, a copy of the + * system properties for the calling context should be used. + * @param env a Map object containing the command's environment variables. + * If this parameter is {@code null}, the environment variables for + * the calling context should be used. * @return an integer return code, with zero indicating command success, * non-zero indicating command failure. * @throws ShellException if there was some problem launching the command. */ - int invoke(CommandLine commandLine, CommandInfo cmdInfo) + int invoke(CommandLine commandLine, CommandInfo cmdInfo, + Properties sysProps, Map<String, String> env) throws ShellException; /** @@ -59,22 +58,19 @@ * @param commandLine this provides the command name (alias), the command * arguments and (where relevant) the command's i/o stream context. * @param cmdInfo a CommandInfo descriptor for the command to be run. + * @param sysProps a Properties object containing the command's system + * properties. If this parameter is {@code null}, a copy of the + * system properties for the calling context should be used. + * @param env a Map object containing the command's environment variables. + * If this parameter is {@code null}, the environment variables for + * the calling context should be used. * @return the thread for the command. Calling * {@link java.lang.Thread#start()} will cause the command to * execute. * @throws ShellException if there was some problem launching the command. */ - CommandThread invokeAsynchronous(CommandLine commandLine, CommandInfo cmdInfo) + CommandThread invokeAsynchronous(CommandLine commandLine, CommandInfo cmdInfo, + Properties sysProps, Map<String, String> env) throws ShellException; - /** - * Get the invoker's name. - * - * @return the name. - */ - String getName(); - - boolean isDebugEnabled(); - - void setDebugEnabled(boolean enabled); } Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -29,6 +29,8 @@ import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedActionException; +import java.util.Map; +import java.util.Properties; import org.jnode.shell.help.HelpException; import org.jnode.shell.help.HelpFactory; @@ -45,7 +47,7 @@ */ public class CommandRunner implements Runnable { - private final CommandInvoker invoker; + private final SimpleCommandInvoker invoker; private final CommandIO[] ios; final Class<?> targetClass; final Method method; @@ -53,12 +55,14 @@ final CommandInfo cmdInfo; final CommandLine commandLine; final PrintWriter shellErr; + final Properties sysProps; + final Map<String, String> env; private int rc; - public CommandRunner(CommandInvoker invoker, + public CommandRunner(SimpleCommandInvoker invoker, CommandInfo cmdInfo, Class<?> targetClass, Method method, Object[] args, - CommandIO[] ios) { + CommandIO[] ios, Properties sysProps, Map<String, String> env) { this.invoker = invoker; this.targetClass = targetClass; this.method = method; @@ -67,10 +71,13 @@ this.args = args; this.ios = ios; this.shellErr = ios[Command.SHELL_ERR].getPrintWriter(); + this.env = env; + this.sysProps = sysProps; } - public CommandRunner(CommandInvoker invoker, - CommandInfo cmdInfo, CommandLine commandLine, CommandIO[] ios) { + public CommandRunner(SimpleCommandInvoker invoker, + CommandInfo cmdInfo, CommandLine commandLine, CommandIO[] ios, + Properties sysProps, Map<String, String> env) { this.invoker = invoker; this.targetClass = null; this.method = null; @@ -79,6 +86,8 @@ this.commandLine = commandLine; this.ios = ios; this.shellErr = ios[Command.SHELL_ERR].getPrintWriter(); + this.env = env; + this.sysProps = sysProps; } public void run() { @@ -199,4 +208,11 @@ return commandLine != null ? commandLine.getCommandName() : null; } + public Properties getSysProps() { + return sysProps; + } + + public Map<String, String> getEnv() { + return env; + } } Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -38,6 +38,8 @@ import java.text.DateFormat; import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.StringTokenizer; import javax.naming.NameNotFoundException; @@ -151,7 +153,7 @@ */ private String lastInputLine = ""; - private CommandInvoker invoker; + private SimpleCommandInvoker invoker; private String invokerName; private CommandInterpreter interpreter; @@ -573,11 +575,19 @@ * command is run using the CommandShell's current invoker. * * @param cmdLine the CommandLine object. + * @param env + * @param sysProps * @return the command's return code * @throws ShellException */ - public int invoke(CommandLine cmdLine, CommandInfo cmdInfo) throws ShellException { - return this.invoker.invoke(cmdLine, cmdInfo); + public int invoke(CommandLine cmdLine, CommandInfo cmdInfo, + Properties sysProps, Map<String, String> env) + throws ShellException { + if (this.invoker instanceof CommandInvoker) { + return ((CommandInvoker) this.invoker).invoke(cmdLine, cmdInfo, sysProps, env); + } else { + return this.invoker.invoke(cmdLine, cmdInfo); + } } /** @@ -843,7 +853,7 @@ } } - public CommandInvoker getDefaultCommandInvoker() { + public SimpleCommandInvoker getDefaultCommandInvoker() { return ShellUtils.createInvoker("default", this); } Modified: trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -49,7 +49,7 @@ * @author Sam Reid * @author cr...@jn... */ -public class DefaultCommandInvoker implements CommandInvoker { +public class DefaultCommandInvoker implements SimpleCommandInvoker { private final PrintWriter err; private final CommandShell shell; @@ -58,7 +58,7 @@ private static final Class<?>[] MAIN_ARG_TYPES = new Class[] {String[].class}; public static final Factory FACTORY = new Factory() { - public CommandInvoker create(CommandShell shell) { + public SimpleCommandInvoker create(CommandShell shell) { return new DefaultCommandInvoker(shell); } Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -102,7 +102,7 @@ shell.addCommandToHistory(line); try { CommandInfo cmdInfo = cmd.parseCommandLine(shell); - return shell.invoke(cmd, cmdInfo); + return shell.invoke(cmd, cmdInfo, null, null); } catch (CommandSyntaxException ex) { throw new ShellException("Command arguments don't match syntax", ex); } Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -249,7 +249,7 @@ desc.commandLine.setStreams(new CommandIO[] {in, out, err, CommandLine.DEFAULT_STDERR}); try { CommandInfo cmdInfo = desc.commandLine.parseCommandLine(shell); - return shell.invoke(desc.commandLine, cmdInfo); + return shell.invoke(desc.commandLine, cmdInfo, null, null); } catch (CommandSyntaxException ex) { throw new ShellException( "Command arguments don't match syntax", ex); Modified: trunk/shell/src/shell/org/jnode/shell/ShellManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellManager.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/ShellManager.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -48,15 +48,15 @@ */ public void registerShell(Shell currentShell); - public void registerInvokerFactory(CommandInvoker.Factory factory); + public void registerInvokerFactory(SimpleCommandInvoker.Factory factory); public void registerInterpreterFactory(CommandInterpreter.Factory factory); - public void unregisterInvokerFactory(CommandInvoker.Factory factory); + public void unregisterInvokerFactory(SimpleCommandInvoker.Factory factory); public void unregisterInterpreterFactory(CommandInterpreter.Factory factory); - public CommandInvoker createInvoker(String name, CommandShell shell) + public SimpleCommandInvoker createInvoker(String name, CommandShell shell) throws IllegalArgumentException; public CommandInterpreter createInterpreter(String name) Modified: trunk/shell/src/shell/org/jnode/shell/ShellUtils.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ShellUtils.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/ShellUtils.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -92,7 +92,7 @@ return getShellManager().getCurrentShell().getSyntaxManager(); } - public static void registerCommandInvoker(CommandInvoker.Factory factory) + public static void registerCommandInvoker(SimpleCommandInvoker.Factory factory) throws NameNotFoundException { getShellManager().registerInvokerFactory(factory); } @@ -102,7 +102,7 @@ getShellManager().registerInterpreterFactory(factory); } - public static CommandInvoker createInvoker(String name, CommandShell shell) + public static SimpleCommandInvoker createInvoker(String name, CommandShell shell) throws IllegalArgumentException { try { return getShellManager().createInvoker(name, shell); Added: trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -0,0 +1,80 @@ +/* + * $Id: CommandInvoker.java 4977 2009-02-02 09:09:41Z lsantha $ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell; + +/* + * User: Sam Reid Date: Dec 20, 2003 Time: 1:18:31 AM Copyright (c) Dec 20, 2003 + * by Sam Reid + */ + +/** + * This is the common API for the various mechanisms for running 'commands'. + * + * @author Sam Reid + * @author cr...@jn... + */ +public interface SimpleCommandInvoker { + + public interface Factory { + SimpleCommandInvoker create(CommandShell shell); + + String getName(); + } + + /** + * Run a command synchronously, passing back the resulting return code. + * + * @param commandLine this provides the command name (alias), the command + * arguments and (where relevant) the command's i/o stream context. + * @param cmdInfo a CommandInfo descriptor for the command to be run. + * @return an integer return code, with zero indicating command success, + * non-zero indicating command failure. + * @throws ShellException if there was some problem launching the command. + */ + int invoke(CommandLine commandLine, CommandInfo cmdInfo) + throws ShellException; + + /** + * Create a thread for running a command asynchronously. This can be used + * for running and for assembling command pipelines. + * + * @param commandLine this provides the command name (alias), the command + * arguments and (where relevant) the command's i/o stream context. + * @param cmdInfo a CommandInfo descriptor for the command to be run. + * @return the thread for the command. Calling + * {@link java.lang.Thread#start()} will cause the command to + * execute. + * @throws ShellException if there was some problem launching the command. + */ + CommandThread invokeAsynchronous(CommandLine commandLine, CommandInfo cmdInfo) + throws ShellException; + + /** + * Get the invoker's name. + * + * @return the name. + */ + String getName(); + + boolean isDebugEnabled(); + + void setDebugEnabled(boolean enabled); +} Modified: trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -40,7 +40,7 @@ public class ThreadCommandInvoker extends AsyncCommandInvoker { public static final Factory FACTORY = new Factory() { - public CommandInvoker create(CommandShell shell) { + public SimpleCommandInvoker create(CommandShell shell) { return new ThreadCommandInvoker(shell); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -257,7 +257,7 @@ value.length(); // Check that the value is non-null. VariableSlot var = variables.get(name); if (var == null) { - variables.put(name, new VariableSlot(value, false)); + variables.put(name, new VariableSlot(name, value, false)); } else { var.value = value; } @@ -291,7 +291,7 @@ VariableSlot var = variables.get(name); if (var == null) { if (exported) { - variables.put(name, new VariableSlot("", exported)); + variables.put(name, new VariableSlot(name, "", exported)); } } else { var.exported = exported; @@ -901,10 +901,21 @@ } resolvePrintStream(streams[Command.STD_ERR]).println(sb); } - lastReturnCode = interpreter.executeCommand(command, this, streams); + Map<String, String> env = buildEnvFromExports(); + lastReturnCode = interpreter.executeCommand(command, this, streams, null, env); return lastReturnCode; } + private Map<String, String> buildEnvFromExports() { + HashMap<String, String> map = new HashMap<String, String>(variables.size()); + for (VariableSlot var : variables.values()) { + if (var.exported) { + map.put(var.name, var.value); + } + } + return map; + } + PrintStream resolvePrintStream(CommandIO commandIOIF) { return interpreter.resolvePrintStream(commandIOIF); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneControlException.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -22,6 +22,12 @@ import org.jnode.shell.ShellException; +/** + * This exception is used to implement constructs that exit scopes + * in the bjorne interpreter. It should never be thrown by an application. + * + * @author cr...@jn... + */ class BjorneControlException extends ShellException { private static final long serialVersionUID = 1L; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -41,6 +41,8 @@ import java.io.Reader; import java.io.StringWriter; import java.util.HashMap; +import java.util.Map; +import java.util.Properties; import org.jnode.driver.console.CompletionInfo; import org.jnode.shell.CommandInfo; @@ -140,10 +142,12 @@ BUILTINS.put("break", new BreakBuiltin()); BUILTINS.put("continue", new ContinueBuiltin()); BUILTINS.put("exit", new ExitBuiltin()); + BUILTINS.put("export", new ExportBuiltin()); BUILTINS.put("return", new ReturnBuiltin()); BUILTINS.put("set", new SetBuiltin()); BUILTINS.put("shift", new ShiftBuiltin()); BUILTINS.put(".", new SourceBuiltin()); + BUILTINS.put("source", new SourceBuiltin()); BUILTINS.put(":", new ColonBuiltin()); } @@ -325,7 +329,8 @@ } } - int executeCommand(CommandLine cmdLine, BjorneContext context, CommandIO[] streams) + int executeCommand(CommandLine cmdLine, BjorneContext context, CommandIO[] streams, + Properties sysProps, Map<String, String> env) throws ShellException { BjorneBuiltin builtin = BUILTINS.get(cmdLine.getCommandName()); if (builtin != null) { @@ -336,7 +341,7 @@ cmdLine.setStreams(streams); try { CommandInfo cmdInfo = cmdLine.parseCommandLine(shell); - return shell.invoke(cmdLine, cmdInfo); + return shell.invoke(cmdLine, cmdInfo, sysProps, env); } catch (CommandSyntaxException ex) { throw new ShellException("Command arguments don't match syntax", ex); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneParser.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -427,17 +427,17 @@ case TOK_LESSGREAT: case TOK_CLOBBER: arg = tokens.next(); - tt = arg.getTokenType(); - if (tt != TOK_WORD) { - syntaxError("expected a filename after " + token, tt); + int tt2 = arg.getTokenType(); + if (tt2 != TOK_WORD) { + syntaxError("expected a filename after " + token, tt2); } break; case TOK_DLESS: case TOK_DLESSDASH: arg = tokens.next(); - tt = arg.getTokenType(); - if (arg.getTokenType() != TOK_WORD) { - syntaxError("expected a here-end marker " + token, tt); + int tt3 = arg.getTokenType(); + if (tt3 != TOK_WORD) { + syntaxError("expected a here-end marker " + token, tt3); } // TODO ... need to grab the HERE document ... break; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -169,6 +169,9 @@ public static boolean isName(String str) { int len = str.length(); + if (len == 0) { + return false; + } for (int i = 0; i < len; i++) { char ch = str.charAt(i); switch (ch) { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -492,8 +492,7 @@ case RULE_7b_CONTEXT: int pos = token.getText().indexOf('='); if (pos <= 0 - || !BjorneToken.isName(token.getText() - .substring(0, pos - 1))) { + || !BjorneToken.isName(token.getText().substring(0, pos))) { return token; } return remakeToken(TOK_ASSIGNMENT, token); Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ExitBuiltin.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -25,6 +25,12 @@ import org.jnode.shell.CommandLine; import org.jnode.shell.ShellException; +/** + * This class implements the 'exit' built-in. This is done by throwing a + * BjorneControlException with code 'BRANCH_EXIT'. + * + * @author cr...@jn... + */ final class ExitBuiltin extends BjorneBuiltin { @SuppressWarnings("deprecation") public int invoke(CommandLine command, BjorneInterpreter interpreter, Added: trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ExportBuiltin.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -0,0 +1,61 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.bjorne; + +import java.util.Iterator; + +import org.jnode.shell.CommandLine; +import org.jnode.shell.ShellException; + +/** + * This class implements the 'export' built-in. + * + * @author cr...@jn... + */ +final class ExportBuiltin extends BjorneBuiltin { + @SuppressWarnings("deprecation") + public int invoke(CommandLine command, BjorneInterpreter interpreter, + BjorneContext context) throws ShellException { + Iterator<String> args = command.iterator(); + if (!args.hasNext()) { + throw new BjorneControlException(BjorneInterpreter.BRANCH_EXIT, + context.getParent().getLastReturnCode()); + } + while (args.hasNext()) { + String arg = args.next(); + int pos = arg.indexOf('='); + if (pos == -1) { + context.getParent().setExported(arg, true); + } else if (pos == 0) { + error("export: " + arg + ": not a valid identifier", context); + } else { + String name = arg.substring(0, pos); + String value = arg.substring(pos + 1); + if (!BjorneToken.isName(name)) { + error("export: " + name + ": not a valid identifier", context); + } + context.getParent().setVariable(name, value); + context.getParent().setExported(name, true); + } + } + return 0; + } +} Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/VariableSlot.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -23,19 +23,24 @@ class VariableSlot { public String value; - + public final String name; public boolean exported; - public VariableSlot(String value, boolean exported) { + public VariableSlot(String name, String value, boolean exported) { + if (name == null) { + throw new ShellFailureException("null name"); + } if (value == null) { throw new ShellFailureException("null value"); } this.value = value; this.exported = exported; + this.name = name; } public VariableSlot(VariableSlot other) { this.value = other.value; this.exported = other.exported; + this.name = other.name; } } Modified: trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/command/PrintEnvCommand.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -50,7 +50,8 @@ * Execute this command */ public void execute() throws Exception { - final Map<String, String> env = (Map<String, String>) AccessController.doPrivileged(new GetEnvAction()); + final Map<String, String> env = + (Map<String, String>) AccessController.doPrivileged(new GetEnvAction()); final TreeMap<String, String> sortedEnv = new TreeMap<String, String>(env); final PrintWriter out = getOutput().getPrintWriter(); for (Map.Entry<String, String> entry : sortedEnv.entrySet()) { Modified: trunk/shell/src/shell/org/jnode/shell/def/DefaultShellManager.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/def/DefaultShellManager.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/def/DefaultShellManager.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -23,7 +23,7 @@ import java.util.HashMap; import org.jnode.shell.CommandInterpreter; -import org.jnode.shell.CommandInvoker; +import org.jnode.shell.SimpleCommandInvoker; import org.jnode.shell.CommandShell; import org.jnode.shell.Shell; import org.jnode.shell.ShellManager; @@ -40,8 +40,8 @@ private final InheritableThreadLocal<Shell> currentShell = new InheritableThreadLocal<Shell>(); - private final HashMap<String, CommandInvoker.Factory> invokerFactories = - new HashMap<String, CommandInvoker.Factory>(); + private final HashMap<String, SimpleCommandInvoker.Factory> invokerFactories = + new HashMap<String, SimpleCommandInvoker.Factory>(); private final HashMap<String, CommandInterpreter.Factory> interpreterFactories = new HashMap<String, CommandInterpreter.Factory>(); @@ -70,8 +70,8 @@ return factory.create(); } - public CommandInvoker createInvoker(String name, CommandShell shell) throws IllegalArgumentException { - CommandInvoker.Factory factory = invokerFactories.get(name); + public SimpleCommandInvoker createInvoker(String name, CommandShell shell) throws IllegalArgumentException { + SimpleCommandInvoker.Factory factory = invokerFactories.get(name); if (factory == null) { throw new IllegalArgumentException("Unknown invoker '" + name + "'"); } @@ -82,7 +82,7 @@ interpreterFactories.put(factory.getName(), factory); } - public void registerInvokerFactory(CommandInvoker.Factory factory) { + public void registerInvokerFactory(SimpleCommandInvoker.Factory factory) { invokerFactories.put(factory.getName(), factory); } @@ -90,7 +90,7 @@ interpreterFactories.put(factory.getName(), null); } - public void unregisterInvokerFactory(CommandInvoker.Factory factory) { + public void unregisterInvokerFactory(SimpleCommandInvoker.Factory factory) { invokerFactories.put(factory.getName(), null); } } Modified: trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -23,7 +23,7 @@ import java.io.IOException; import org.jnode.shell.AsyncCommandInvoker; -import org.jnode.shell.CommandInvoker; +import org.jnode.shell.SimpleCommandInvoker; import org.jnode.shell.CommandRunner; import org.jnode.shell.CommandShell; import org.jnode.shell.CommandThread; @@ -37,7 +37,7 @@ public class IsolateCommandInvoker extends AsyncCommandInvoker { public static final Factory FACTORY = new Factory() { - public CommandInvoker create(CommandShell shell) { + public SimpleCommandInvoker create(CommandShell shell) { return new IsolateCommandInvoker(shell); } Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -20,25 +20,34 @@ package org.jnode.shell.proclet; +import java.util.Map; +import java.util.Properties; + import org.jnode.shell.AsyncCommandInvoker; import org.jnode.shell.Command; +import org.jnode.shell.CommandInfo; import org.jnode.shell.CommandInvoker; +import org.jnode.shell.CommandLine; import org.jnode.shell.CommandRunner; import org.jnode.shell.CommandShell; +import org.jnode.shell.CommandThread; import org.jnode.shell.CommandThreadImpl; +import org.jnode.shell.ShellException; +import org.jnode.shell.SimpleCommandInvoker; import org.jnode.shell.io.CommandIO; import org.jnode.vm.VmSystem; /** * This command invoker runs commands in their own proclet, giving each one its - * own stdin,out,err etcetera. + * own standard input / output / error stream, system properties and environment + * variables. * * @author cr...@jn... */ -public class ProcletCommandInvoker extends AsyncCommandInvoker { +public class ProcletCommandInvoker extends AsyncCommandInvoker implements CommandInvoker { public static final Factory FACTORY = new Factory() { - public CommandInvoker create(CommandShell shell) { + public SimpleCommandInvoker create(CommandShell shell) { return new ProcletCommandInvoker(shell); } @@ -58,9 +67,23 @@ return "proclet"; } + public int invoke(CommandLine cmdLine, CommandInfo cmdInfo, + Properties sysProps, Map<String, String> env) + throws ShellException { + CommandRunner cr = setup(cmdLine, cmdInfo, sysProps, env); + return runIt(cmdLine, cmdInfo, cr); + } + + public CommandThread invokeAsynchronous(CommandLine cmdLine, CommandInfo cmdInfo, + Properties sysProps, Map<String, String> env) + throws ShellException { + CommandRunner cr = setup(cmdLine, cmdInfo, sysProps, env); + return forkIt(cmdLine, cmdInfo, cr); + } + protected CommandThreadImpl createThread(CommandRunner cr) { CommandIO[] ios = cr.getIos(); - return ProcletContext.createProclet(cr, null, null, + return ProcletContext.createProclet(cr, cr.getSysProps(), cr.getEnv(), new Object[] { ios[Command.STD_IN].getInputStream(), ios[Command.STD_OUT].getPrintStream(), Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletContext.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -20,10 +20,10 @@ package org.jnode.shell.proclet; +import gnu.java.security.action.GetPropertiesAction; + import java.io.Closeable; import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -32,6 +32,7 @@ import org.jnode.util.ProxyStream; import org.jnode.util.ProxyStreamException; import org.jnode.vm.VmExit; +import org.jnode.vm.VmIOContext; import org.jnode.vm.VmSystem; import org.jnode.vm.isolate.VmIsolate; @@ -62,20 +63,6 @@ Map<String, String> environment, Object[] streams) throws ProcletException { super(parent, nextProcletName()); ProcletContext parentContext = getParentContext(parent); - if (properties == null) { - if (parentContext != null) { - properties = parentContext.properties; - } - if (properties == null) { - properties = AccessController.doPrivileged( - new PrivilegedAction<Properties>() { - public Properties run() { - return System.getProperties(); - } - }); - } - properties = (Properties) properties.clone(); - } if (streams == null) { try { streams = new Object[] { @@ -85,12 +72,20 @@ throw new ProcletException("Broken streams", ex); } } + if (properties == null) { + if (parentContext != null) { + properties = parentContext.properties; + } else { + // FIXME ... temporary + properties = AccessController.doPrivileged(new GetPropertiesAction()); + } + properties = (Properties) properties.clone(); + } if (environment == null) { if (parentContext != null) { - environment = new HashMap<String, String>( - parentContext.environment); + environment = parentContext.environment; } else { - environment = new HashMap<String, String>(); + environment = VmIOContext.getGlobalEnv(); } } this.environment = environment; @@ -128,6 +123,10 @@ public synchronized void setProperties(Properties properties) { this.properties = properties; } + + public synchronized void setEnvironment(Map<String, String> environment) { + this.environment = environment; + } /** * Get the ProcletContext for the current thread. @@ -303,5 +302,4 @@ return getClass().getName() + "[name=" + getName() + ",maxpri=" + getMaxPriority() + ",pid=" + getPid() + ']'; } - } Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java 2009-02-14 20:29:54 UTC (rev 5025) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletIOContext.java 2009-02-15 05:39:30 UTC (rev 5026) @@ -22,14 +22,17 @@ import java.io.InputStream; import java.io.PrintStream; +import java.util.Map; +import java.util.Properties; import org.jnode.vm.IOContext; +import org.jnode.vm.VmIOContext; import org.jnode.vm.VmSystem; /** * The ProcletIOContext is an IOContext implementation that uses Proxy streams to * direct System.in/out/err traffic to different places depending on the current - * proclet. + * proclet. * * @author Levente S\u00e1ntha * @author cr...@jn... @@ -41,48 +44,8 @@ public ProcletIOContext() { } - public synchronized void setGlobalInStream(InputStream is) { - doSetIn(is, GLOBAL_STREAM_ID); - } - - public synchronized void setGlobalOutStream(PrintStream ps) { - doSetOut(ps, GLOBAL_STREAM_ID); - } - - public synchronized void setGlobalErrStream(PrintStream is) { - doSetErr(is, GLOBAL_STREAM_ID); - } - - public synchronized InputStream getGlobalInStream() { - return ((ProcletProxyInputStream) System.in).getProxiedStream(GLOBAL_STREAM_ID); - } - - public synchronized PrintStream getGlobalOutStream() { - return ((ProcletProxyPrintStream) System.out).getProxiedStream(GLOBAL_STREAM_ID); - } - - public synchronized PrintStream getGlobalErrStream() { - return ((ProcletProxyPrintStream) System.err).getProxiedStream(GLOBAL_STREAM_ID); - } - public synchronized void setSystemIn(InputStream is) { - doSetIn(is, getCurrentPid()); - } - - public synchronized void setSystemOut(PrintStream ps) { - doSetOut(ps, getCurrentPid()); - } - - public synchronized void setSystemErr(PrintStream ps) { - doSetErr(ps, getCurrentPid()); - } - - private int getCurrentPid() { - ProcletContext procletContext = ProcletContext.currentProcletContext(); - return (procletContext == null) ? GLOBAL_STREAM_ID : procletContext.getPid(); - } - - private void doSetIn(InputStream is, int pid) { + int pid = getCurrentPid(); if (is instanceof ProcletProxyInputStream) { is = ((ProcletProxyInputStream) is).getProxiedStream(pid); } @@ -91,7 +54,8 @@ VmSystem.setStaticField(System.class, "in", newProxyStream); } - private void doSetOut(PrintStream ps, int pid) { + public synchronized void setSystemOut(PrintStream ps) { + int pid = getCurrentPid(); if (ps instanceof ProcletProxyPrintStream) { ps = ((ProcletProxyPrintStream) ps).getProxiedStream(pid); } @@ -100,7 +64,8 @@ VmSystem.setStaticField(System.class, "out", newProxyStream); } - private void doSetErr(PrintStream ps, int pid) { + public synchronized void setSystemErr(PrintStream ps) { + int pid = getCurrentPid(); if (ps instanceof ProcletProxyPrintStream) { ps = ((ProcletProxyPrintStream) ps).getProxiedStream(pid); } @@ -108,7 +73,28 @@ (ProcletProxyPrintStream) System.err, ps, pid); VmSystem.setStaticField(System.class, "err", newProxyStream); } + + public Map<String, String> getEnv() { + return ProcletContext.currentProcletContext().getEnvironment(); + } + public Propert... [truncated message content] |
From: <kon...@us...> - 2009-02-15 21:29:13
|
Revision: 5029 http://jnode.svn.sourceforge.net/jnode/?rev=5029&view=rev Author: konkubinaten Date: 2009-02-15 21:29:10 +0000 (Sun, 15 Feb 2009) Log Message: ----------- added descriptors for cirrus driver. If you have a cirrus graphics card it should be detected and the (not yet working) cirrus driver will be used by default. Modified Paths: -------------- trunk/all/conf/default-plugin-list.xml Added Paths: ----------- trunk/gui/descriptors/org.jnode.driver.video.cirrus.xml Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2009-02-15 21:26:21 UTC (rev 5028) +++ trunk/all/conf/default-plugin-list.xml 2009-02-15 21:29:10 UTC (rev 5029) @@ -106,6 +106,7 @@ <plugin id="org.jnode.driver.video.cursor"/> <plugin id="org.jnode.driver.video.ati.mach64"/> <plugin id="org.jnode.driver.video.ati.radeon"/> + <plugin id="org.jnode.driver.video.cirrus"/> <plugin id="org.jnode.driver.video.nvidia"/> <plugin id="org.jnode.driver.video.vga"/> <plugin id="org.jnode.driver.video.vgahw"/> Added: trunk/gui/descriptors/org.jnode.driver.video.cirrus.xml =================================================================== --- trunk/gui/descriptors/org.jnode.driver.video.cirrus.xml (rev 0) +++ trunk/gui/descriptors/org.jnode.driver.video.cirrus.xml 2009-02-15 21:29:10 UTC (rev 5029) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.driver.video.cirrus" + name="JNode Cirrus driver" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + <requires> + <import plugin="org.jnode.awt"/> + <import plugin="org.jnode.driver.video"/> + <import plugin="org.jnode.driver.bus.pci"/> + </requires> + + <runtime> + <library name="jnode-gui.jar"> + <export name="org.jnode.driver.video.cirrus.*"/> + </library> + </runtime> + + <extension point="org.jnode.driver.mappers"> + <mapper id="1013:00B8" architecture="gd5446" name="Cirrus Logic GD 5446" driver-class="org.jnode.driver.video.cirrus.CirrusDriver" class="org.jnode.driver.bus.pci.PCIDeviceToDriverMapper"/> + </extension> + + <extension point="org.jnode.security.permissions"> + <permission class="org.jnode.system.ResourcePermission" name="ioports"/> + </extension> + +</plugin> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-02-15 22:30:56
|
Revision: 5031 http://jnode.svn.sourceforge.net/jnode/?rev=5031&view=rev Author: fduminy Date: 2009-02-15 22:30:50 +0000 (Sun, 15 Feb 2009) Log Message: ----------- fixed checkstyle config files for eclipse Modified Paths: -------------- trunk/builder/.checkstyle trunk/core/.checkstyle trunk/distr/.checkstyle trunk/fs/.checkstyle trunk/gui/.checkstyle trunk/net/.checkstyle trunk/shell/.checkstyle Added Paths: ----------- trunk/docs/.checkstyle trunk/sound/.checkstyle trunk/textui/.checkstyle Modified: trunk/builder/.checkstyle =================================================================== --- trunk/builder/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/builder/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,9 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> - <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> + <local-check-config name="JNode checkstyle - javadoc" location="/all/new_checks.xml" type="project" description=""> + <additional-data name="protect-config-file" value="true"/> + </local-check-config> + <fileset name="tous" enabled="true" check-config-name="JNode checkstyle - javadoc" local="true"> <file-match-pattern match-pattern="." include-pattern="true"/> </fileset> <filter name="FilesFromPackage" enabled="true"> Modified: trunk/core/.checkstyle =================================================================== --- trunk/core/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/core/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> Modified: trunk/distr/.checkstyle =================================================================== --- trunk/distr/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/distr/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,9 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> - <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> + <local-check-config name="JNode checkstyle - javadoc" location="/all/new_checks.xml" type="project" description=""> + <additional-data name="protect-config-file" value="true"/> + </local-check-config> + <fileset name="tous" enabled="true" check-config-name="JNode checkstyle - javadoc" local="true"> <file-match-pattern match-pattern="." include-pattern="true"/> </fileset> <filter name="NonSrcDirs" enabled="true"/> Added: trunk/docs/.checkstyle =================================================================== --- trunk/docs/.checkstyle (rev 0) +++ trunk/docs/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <fileset name="tous" enabled="true" check-config-name="Sun Checks" local="false"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> +</fileset-config> Modified: trunk/fs/.checkstyle =================================================================== --- trunk/fs/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/fs/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> Modified: trunk/gui/.checkstyle =================================================================== --- trunk/gui/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/gui/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> Modified: trunk/net/.checkstyle =================================================================== --- trunk/net/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/net/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> Modified: trunk/shell/.checkstyle =================================================================== --- trunk/shell/.checkstyle 2009-02-15 22:09:28 UTC (rev 5030) +++ trunk/shell/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <fileset-config file-format-version="1.2.0" simple-config="true"> - <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <local-check-config name="JNode checkstyle" location="/all/jnode_checks.xml" type="project" description=""> <additional-data name="protect-config-file" value="true"/> </local-check-config> <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> Added: trunk/sound/.checkstyle =================================================================== --- trunk/sound/.checkstyle (rev 0) +++ trunk/sound/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <fileset name="tous" enabled="true" check-config-name="Sun Checks" local="false"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> +</fileset-config> Added: trunk/textui/.checkstyle =================================================================== --- trunk/textui/.checkstyle (rev 0) +++ trunk/textui/.checkstyle 2009-02-15 22:30:50 UTC (rev 5031) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <fileset name="tous" enabled="true" check-config-name="Sun Checks" local="false"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> +</fileset-config> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-02-15 23:01:57
|
Revision: 5030 http://jnode.svn.sourceforge.net/jnode/?rev=5030&view=rev Author: fduminy Date: 2009-02-15 22:09:28 +0000 (Sun, 15 Feb 2009) Log Message: ----------- renamed eclipse projects to match their directory names (JNode-Shell -> shell, JNode-All -> all, ....) Modified Paths: -------------- trunk/all/.classpath trunk/all/.project trunk/builder/.classpath trunk/builder/.project trunk/core/.project trunk/distr/.classpath trunk/distr/.project trunk/docs/.project trunk/fs/.classpath trunk/fs/.project trunk/gui/.classpath trunk/gui/.project trunk/net/.classpath trunk/net/.project trunk/shell/.classpath trunk/shell/.project trunk/sound/.project trunk/textui/.classpath trunk/textui/.project Modified: trunk/all/.classpath =================================================================== --- trunk/all/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/all/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="/JNode-Builder"/> - <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="src" path="/JNode-FS"/> - <classpathentry kind="src" path="/JNode-GUI"/> - <classpathentry kind="src" path="/JNode-Net"/> - <classpathentry kind="src" path="/JNode-Shell"/> + <classpathentry kind="src" path="/builder"/> + <classpathentry kind="src" path="/core"/> + <classpathentry kind="src" path="/fs"/> + <classpathentry kind="src" path="/gui"/> + <classpathentry kind="src" path="/net"/> + <classpathentry kind="src" path="/shell"/> <classpathentry kind="output" path="build"/> </classpath> Modified: trunk/all/.project =================================================================== --- trunk/all/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/all/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-All</name> + <name>all</name> <comment></comment> <projects> <project>JNode-Builder</project> Modified: trunk/builder/.classpath =================================================================== --- trunk/builder/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/builder/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -2,11 +2,11 @@ <classpath> <classpathentry excluding="**/.svn/**" kind="src" path="src/builder"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/configure"/> - <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="src" path="/JNode-FS"/> - <classpathentry kind="lib" path="/JNode-Core/lib/ant.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> - <classpathentry kind="src" path="/JNode-Shell"/> + <classpathentry kind="src" path="/core"/> + <classpathentry kind="src" path="/fs"/> + <classpathentry kind="lib" path="/core/lib/ant.jar"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="src" path="/shell"/> <classpathentry kind="lib" path="lib/xml-apis.jar"/> <classpathentry kind="lib" path="lib/bcel-5.1.jar"/> <classpathentry kind="lib" path="lib/nanoxml-2.2.3.jar"/> Modified: trunk/builder/.project =================================================================== --- trunk/builder/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/builder/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Builder</name> + <name>builder</name> <comment></comment> <projects> <project>JNode-Core</project> Modified: trunk/core/.project =================================================================== --- trunk/core/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/core/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Core</name> + <name>core</name> <comment></comment> <projects> </projects> Modified: trunk/distr/.classpath =================================================================== --- trunk/distr/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/distr/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -3,22 +3,23 @@ <classpathentry excluding="**/.svn/**" kind="src" path="src/install"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/emu"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> - <classpathentry kind="src" path="/JNode-Core"/> + <classpathentry kind="src" path="/core"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/apps"/> - <classpathentry kind="src" path="/JNode-GUI"/> + <classpathentry kind="src" path="/gui"/> <classpathentry kind="lib" path="lib/telnetd.jar"/> <classpathentry kind="lib" path="lib/jetty-6.1.5.jar"/> <classpathentry kind="lib" path="lib/jetty-util-6.1.5.jar"/> <classpathentry kind="lib" path="lib/jsp-2.1.jar"/> <classpathentry kind="lib" path="lib/jsp-api-2.1.jar"/> <classpathentry kind="lib" path="lib/servlet-api-2.5-6.1.5.jar"/> - <classpathentry kind="src" path="/JNode-Shell"/> - <classpathentry kind="src" path="/JNode-TextUI"/> - <classpathentry combineaccessrules="false" kind="src" path="/JNode-FS"/> - <classpathentry kind="lib" path="/JNode-Shell/lib/bsh-2.0b5.jar"/> + <classpathentry kind="src" path="/shell"/> + <classpathentry kind="src" path="/textui"/> + <classpathentry combineaccessrules="false" kind="src" path="/fs"/> + <classpathentry kind="lib" path="/shell/lib/bsh-2.0b5.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="lib" path="lib/commons-logging.jar"/> <classpathentry kind="lib" path="lib/derby.jar"/> <classpathentry kind="lib" path="lib/derbynet.jar"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/distr/.project =================================================================== --- trunk/distr/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/distr/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Distr</name> + <name>distr</name> <comment></comment> <projects> <project>JNode-Core</project> Modified: trunk/docs/.project =================================================================== --- trunk/docs/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/docs/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Docs</name> + <name>docs</name> <comment></comment> <projects> </projects> Modified: trunk/fs/.classpath =================================================================== --- trunk/fs/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/fs/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -3,20 +3,20 @@ <classpathentry excluding="**/.svn/**" kind="src" path="src/fs"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> - <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> - <classpathentry kind="src" path="/JNode-Shell"/> - <classpathentry kind="lib" path="/JNode-Core/lib/junit.jar"/> + <classpathentry kind="src" path="/shell"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="/JNode-Core/lib/ant.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/jmock-1.0.1.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/jmock-cglib-1.0.1.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/cglib-2.1.jar"/> <classpathentry kind="lib" path="lib/edtftpj-1.5.2.jar"/> <classpathentry kind="lib" path="lib/jcifs-1.2.6.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/commons-net-1.1.0.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/jcfe.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/jfunc.jar"/> - <classpathentry combineaccessrules="false" kind="src" path="/JNode-Net"/> + <classpathentry combineaccessrules="false" kind="src" path="/net"/> + <classpathentry kind="src" path="/core"/> + <classpathentry kind="lib" path="/core/lib/ant.jar"/> + <classpathentry kind="lib" path="/core/lib/cglib-2.1.jar"/> + <classpathentry kind="lib" path="/core/lib/commons-net-1.1.0.jar"/> + <classpathentry kind="lib" path="/core/lib/jcfe.jar"/> + <classpathentry kind="lib" path="/core/lib/jfunc.jar"/> + <classpathentry kind="lib" path="/core/lib/jmock-1.0.1.jar"/> + <classpathentry kind="lib" path="/core/lib/jmock-cglib-1.0.1.jar"/> + <classpathentry kind="lib" path="/core/lib/junit.jar"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/fs/.project =================================================================== --- trunk/fs/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/fs/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-FS</name> + <name>fs</name> <comment></comment> <projects> <project>JNode-Core</project> Modified: trunk/gui/.classpath =================================================================== --- trunk/gui/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/gui/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -6,8 +6,8 @@ <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/thinlet"/> - <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> - <classpathentry kind="src" path="/JNode-Shell"/> + <classpathentry kind="src" path="/core"/> + <classpathentry kind="src" path="/shell"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/gui/.project =================================================================== --- trunk/gui/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/gui/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-GUI</name> + <name>gui</name> <comment></comment> <projects> <project>JNode-Core</project> Modified: trunk/net/.classpath =================================================================== --- trunk/net/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/net/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -3,15 +3,15 @@ <classpathentry excluding="**/.svn/**" kind="src" path="src/net"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/driver"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> - <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="src" path="/core"/> <classpathentry kind="lib" path="lib/oncrpc.jar"/> - <classpathentry kind="src" path="/JNode-Shell"/> - <classpathentry kind="lib" path="/JNode-Core/lib/gnu-crypto.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/javax-crypto.jar"/> + <classpathentry kind="src" path="/shell"/> <classpathentry kind="lib" path="lib/jsch-0.1.24.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/commons-net-1.1.0.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/junit.jar"/> <classpathentry kind="lib" path="lib/dnsjava-1.6.6.jar" sourcepath="lib/dnsjava-1.6.6-src.zip"/> + <classpathentry kind="lib" path="/core/lib/commons-net-1.1.0.jar"/> + <classpathentry kind="lib" path="/core/lib/gnu-crypto.jar"/> + <classpathentry kind="lib" path="/core/lib/javax-crypto.jar"/> + <classpathentry kind="lib" path="/core/lib/junit.jar"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/net/.project =================================================================== --- trunk/net/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/net/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Net</name> + <name>net</name> <comment></comment> <projects> <project>JNode-Core</project> Modified: trunk/shell/.classpath =================================================================== --- trunk/shell/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/shell/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -3,13 +3,13 @@ <classpathentry excluding="**/.svn/**" kind="src" path="src/shell"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/emu"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/test"/> - <classpathentry kind="src" path="/JNode-Core"/> - <classpathentry kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/junit.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/ant.jar"/> - <classpathentry kind="lib" path="/JNode-Core/lib/ant-launcher.jar"/> + <classpathentry kind="src" path="/core"/> <classpathentry exported="true" kind="lib" path="lib/bsh-2.0b5.jar"/> <classpathentry kind="lib" path="lib/rhino1.6r5-jsr223.jar"/> - <classpathentry kind="lib" path="/JNode-Builder/lib/nanoxml-2.2.3.jar"/> + <classpathentry kind="lib" path="/core/lib/ant-launcher.jar"/> + <classpathentry kind="lib" path="/core/lib/ant.jar"/> + <classpathentry kind="lib" path="/core/lib/junit.jar"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="lib" path="/builder/lib/nanoxml-2.2.3.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/shell/.project =================================================================== --- trunk/shell/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/shell/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Shell</name> + <name>shell</name> <comment></comment> <projects> <project>JNode-Core</project> Modified: trunk/sound/.project =================================================================== --- trunk/sound/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/sound/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-Sound</name> + <name>sound</name> <comment></comment> <projects> </projects> Modified: trunk/textui/.classpath =================================================================== --- trunk/textui/.classpath 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/textui/.classpath 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/textui"/> - <classpathentry exported="true" kind="src" path="/JNode-Core"/> - <classpathentry exported="true" kind="lib" path="/JNode-Core/lib/log4j-1.2.8.jar"/> - <classpathentry exported="true" kind="src" path="/JNode-Shell"/> + <classpathentry exported="true" kind="src" path="/core"/> + <classpathentry exported="true" kind="src" path="/shell"/> + <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/textui/.project =================================================================== --- trunk/textui/.project 2009-02-15 21:29:10 UTC (rev 5029) +++ trunk/textui/.project 2009-02-15 22:09:28 UTC (rev 5030) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>JNode-TextUI</name> + <name>textui</name> <comment></comment> <projects> <project>JNode-Core</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-16 20:48:10
|
Revision: 5038 http://jnode.svn.sourceforge.net/jnode/?rev=5038&view=rev Author: lsantha Date: 2009-02-16 20:48:06 +0000 (Mon, 16 Feb 2009) Log Message: ----------- Added fragment org.classpath.ext.security. Modified Paths: -------------- trunk/all/conf/default-plugin-list.xml Added Paths: ----------- trunk/core/descriptors/org.classpath.ext.security.xml Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2009-02-16 20:45:42 UTC (rev 5037) +++ trunk/all/conf/default-plugin-list.xml 2009-02-16 20:48:06 UTC (rev 5038) @@ -27,6 +27,7 @@ <plugin id="org.classpath.ext.imageio"/> <plugin id="org.classpath.ext.management"/> <plugin id="org.classpath.ext.sql"/> + <plugin id="org.classpath.ext.security"/> <plugin id="org.classpath.tools"/> <plugin id="mx4j"/> Copied: trunk/core/descriptors/org.classpath.ext.security.xml (from rev 5025, trunk/core/descriptors/org.classpath.ext.xml.xml) =================================================================== --- trunk/core/descriptors/org.classpath.ext.security.xml (rev 0) +++ trunk/core/descriptors/org.classpath.ext.security.xml 2009-02-16 20:48:06 UTC (rev 5038) @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<fragment id="org.classpath.ext.security" + name="Classpath javax.xml classes" + version="@VERSION@" + plugin-id="rt" + plugin-version="@VERSION@" + provider-name="Classpath" + provider-url="http://classpath.org" + license-name="classpath"> + + <runtime> + <library name="jnode-core.jar"> + <export name="sun.security.util.*"/> + <export name="sun.security.tools.*"/> + <export name="sun.security.timestamp.*"/> + <export name="sun.security.acl.*"/> + <export name="sun.security.ec.*"/> + <export name="sun.security.internal.interfaces*"/> + <export name="sun.security.internal.spec*"/> + <export name="sun.security.internal.*"/> + <export name="sun.security.jca.*"/> + <export name="sun.security.jgss.*"/> + <export name="sun.security.jgss.krb5.*"/> + <export name="sun.security.jgss.spi.*"/> + <export name="sun.security.jgss.spnego.*"/> + <export name="sun.security.jgss.wrapper.*"/> + <export name="sun.security.krb5.*"/> + <export name="sun.security.krb5.internal.*"/> + <export name="sun.security.krb5.internal.ccache.*"/> + <export name="sun.security.krb5.internal.crypto.*"/> + <export name="sun.security.krb5.internal.crypto.dk.*"/> + <export name="sun.security.krb5.internal.rcache.*"/> + <export name="sun.security.krb5.internal.ktab.*"/> + <export name="sun.security.krb5.internal.util.*"/> + <export name="sun.security.pkcs.*"/> + <export name="sun.security.pkcs11.*"/> + <export name="sun.security.pkcs11.wrapper.*"/> + <export name="sun.security.pkcs12.*"/> + <export name="sun.security.provider.*"/> + <export name="sun.security.provider.certpath.*"/> + <export name="sun.security.rsa.*"/> + <export name="sun.security.ssl.*"/> + <export name="sun.security.validator.*"/> + <export name="sun.security.x509.*"/> + <export name="com.sun.crypto.provider.*"/> + <export name="com.sun.net.ssl.*"/> + <export name="com.sun.net.ssl.internal.ssl.*"/> + <export name="com.sun.jarsigner.*"/> + <export name="sun.nio.ch.*"/> + </library> + </runtime> + +</fragment> Property changes on: trunk/core/descriptors/org.classpath.ext.security.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-17 14:52:23
|
Revision: 5042 http://jnode.svn.sourceforge.net/jnode/?rev=5042&view=rev Author: crawley Date: 2009-02-17 14:52:18 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Working on getting black-box testing to work on on JNode ... nearly there Modified Paths: -------------- trunk/all/build.xml trunk/all/conf/tests-plugin-list.xml trunk/builder/.classpath trunk/shell/.classpath trunk/shell/build.xml trunk/shell/descriptors/org.jnode.test.shell.xml trunk/shell/src/emu/org/jnode/emu/Emu.java trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java Added Paths: ----------- trunk/shell/descriptors/net.n3.nanoxml.xml trunk/shell/lib/nanoxml-2.2.3.jar Removed Paths: ------------- trunk/builder/lib/nanoxml-2.2.3.jar Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/all/build.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -69,7 +69,7 @@ <property name="derby.jar" value="${root.dir}/distr/lib/derby.jar" /> <property name="derbynet.jar" value="${root.dir}/distr/lib/derbynet.jar" /> <property name="derbytools.jar" value="${root.dir}/distr/lib/derbytools.jar" /> - <property name="nanoxml-java.jar" value="${root.dir}/builder/lib/nanoxml-2.2.3.jar" /> + <property name="nanoxml-java.jar" value="${root.dir}/shell/lib/nanoxml-2.2.3.jar" /> <!-- libraries needed to run tests --> <property name="jmock-cglib.jar" value="${root.dir}/core/lib/jmock-cglib-1.0.1.jar"/> @@ -256,6 +256,7 @@ <libalias name="javax-crypto.jar" alias="${javax-crypto.jar}"/> <libalias name="log4j.jar" alias="${log4j.jar}"/> <libalias name="beanshell.jar" alias="${beanshell.jar}"/> + <libalias name="nanoxml-java.jar" alias="${nanoxml-java.jar}"/> <libalias name="js.jar" alias="${js.jar}"/> <libalias name="lw.jar" alias="${lw.jar}"/> <libalias name="thinlet.jar" alias="${thinlet.jar}"/> Modified: trunk/all/conf/tests-plugin-list.xml =================================================================== --- trunk/all/conf/tests-plugin-list.xml 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/all/conf/tests-plugin-list.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -16,6 +16,7 @@ <plugin id="net.sf.cglib"/> <plugin id="org.jmock.cglib"/> <plugin id="org.jmock"/> + <plugin id="net.n3.nanoxml"/> <plugin id="org.jnode.test"/> <plugin id="org.jnode.test.fs"/> Modified: trunk/builder/.classpath =================================================================== --- trunk/builder/.classpath 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/builder/.classpath 2009-02-17 14:52:18 UTC (rev 5042) @@ -9,6 +9,6 @@ <classpathentry kind="src" path="/shell"/> <classpathentry kind="lib" path="lib/xml-apis.jar"/> <classpathentry kind="lib" path="lib/bcel-5.1.jar"/> - <classpathentry kind="lib" path="lib/nanoxml-2.2.3.jar"/> + <classpathentry kind="lib" path="/shell/lib/nanoxml-2.2.3.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Deleted: trunk/builder/lib/nanoxml-2.2.3.jar =================================================================== (Binary files differ) Modified: trunk/shell/.classpath =================================================================== --- trunk/shell/.classpath 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/.classpath 2009-02-17 14:52:18 UTC (rev 5042) @@ -10,6 +10,6 @@ <classpathentry kind="lib" path="/core/lib/ant.jar"/> <classpathentry kind="lib" path="/core/lib/junit.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> - <classpathentry kind="lib" path="/builder/lib/nanoxml-2.2.3.jar"/> + <classpathentry kind="lib" path="lib/nanoxml-2.2.3.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/shell/build.xml =================================================================== --- trunk/shell/build.xml 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/build.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -10,7 +10,7 @@ <!-- Subproject specific classpath --> <path id="my-cp"> <pathelement location="${jnode-core.jar}"/> - <pathelement location="${basedir}/../builder/lib/nanoxml-2.2.3.jar"/> + <pathelement location="${nanoxml-java.jar}"/> <path refid="cp"/> </path> @@ -19,7 +19,8 @@ <mkdir dir="${my-classes.dir}"/> <jnode.copy-descriptors/> <copy todir="${my-classes.dir}"> - <fileset dir="${my-src.dir}/shell" excludes="**/*.java,**/package.html"/> + <fileset dir="${my-src.dir}/shell" excludes="**/*.java,**/package.html"/> + <fileset dir="${my-src.dir}/test" excludes="**/*.java,**/package.html"/> </copy> </target> Added: trunk/shell/descriptors/net.n3.nanoxml.xml =================================================================== --- trunk/shell/descriptors/net.n3.nanoxml.xml (rev 0) +++ trunk/shell/descriptors/net.n3.nanoxml.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="net.n3.nanoxml" + name="NanoXML Java classes" + version="2.2.3" + provider-name="nanoxml.org" + license-name="zlib"> + + <runtime> + <library name="nanoxml-java.jar"> + <export name="*"/> + </library> + </runtime> + +</plugin> \ No newline at end of file Modified: trunk/shell/descriptors/org.jnode.test.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.test.shell.xml 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/descriptors/org.jnode.test.shell.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -13,6 +13,7 @@ <import plugin="org.jnode.shell.help"/> <import plugin="org.jnode.shell.syntax"/> <import plugin="org.junit" version="3.8"/> + <import plugin="net.n3.nanoxml"/> <import plugin="org.jnode.shell.help"/> <import plugin="org.jnode.testrunner"/> </requires> Added: trunk/shell/lib/nanoxml-2.2.3.jar =================================================================== (Binary files differ) Property changes on: trunk/shell/lib/nanoxml-2.2.3.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/shell/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/src/emu/org/jnode/emu/Emu.java 2009-02-17 14:52:18 UTC (rev 5042) @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.util.HashSet; import javax.naming.NamingException; @@ -59,7 +60,7 @@ }; // FIXME configuring a hard-coded list of command plugins is a bad idea. - private static final String[] DEFAULT_PLUGIN_NAMES = new String[] { + private static final String[] DEFAULT_PLUGIN_IDS = new String[] { "org.jnode.shell.command", "org.jnode.shell.command.driver.console", "org.jnode.apps.editor", @@ -70,9 +71,10 @@ private final File root; private final AliasManager aliasMgr; private final SyntaxManager syntaxMgr; + private final HashSet<String> configuredPlugins = new HashSet<String>(); public Emu(File root) throws EmuException { - this(root, DEFAULT_PLUGIN_NAMES); + this(root, DEFAULT_PLUGIN_IDS); } /** @@ -94,7 +96,7 @@ aliasMgr = new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); syntaxMgr = new DefaultSyntaxManager(new DummyExtensionPoint()).createSyntaxManager(); for (String pluginName : pluginNames) { - configurePluginCommands(pluginName); + configurePlugin(pluginName); } System.setProperty("jnode.invoker", "thread"); System.setProperty("jnode.interpreter", "redirecting"); @@ -111,13 +113,16 @@ /** * Configure any command classes specified by a given plugin's descriptor * - * @param pluginName the plugin to be processed + * @param pluginId the plugin to be processed * @throws EmuException */ - public void configurePluginCommands(String pluginName) throws EmuException { - XMLElement pluginDescriptor = loadPluginDescriptor(pluginName); - extractAliases(pluginDescriptor); - extractSyntaxBundles(pluginDescriptor); + public void configurePlugin(String pluginId) throws EmuException { + if (!configuredPlugins.contains(pluginId)) { + XMLElement pluginDescriptor = loadPluginDescriptor(pluginId); + extractAliases(pluginDescriptor); + extractSyntaxBundles(pluginDescriptor); + configuredPlugins.add(pluginId); + } } /** Modified: trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/src/test/org/jnode/test/shell/bjorne/bjorne-shell-tests.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -613,9 +613,20 @@ </testSpec> <testSpec title="redirection" command="test" runMode="AS_SCRIPT" rc="0"> <script>#!bjorne - echo > @TEMP_DIR@/blablah Hi mum + echo > @TEMP_DIR@/1 Hi mum + echo > @TEMP_DIR@/2 Hi mum + echo >> @TEMP_DIR@/2 Hi mum again + echo Hello mother + echo Hello mother again 1>&2 </script> - <file name="blablah" input="false">Hi mum -</file> + <file name="1" input="false">Hi mum +</file> + <file name="2" input="false">Hi mum +Hi mum again +</file> + <output>Hello mother +</output> + <error>Hello mother again +</error> </testSpec> </testSet> \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/src/test/org/jnode/test/shell/command/posix/posix-command-tests.xml 2009-02-17 14:52:18 UTC (rev 5042) @@ -12,4 +12,42 @@ <output>2 </output> </testSpec> + <testSpec title="expr 2 * 2" command="org.jnode.shell.command.posix.ExprCommand" + runMode="AS_ALIAS" rc="0"> + <arg>2</arg> + <arg>*</arg> + <arg>2</arg> + <output>4 +</output> + </testSpec> + <testSpec title="expr 4 / 2" command="org.jnode.shell.command.posix.ExprCommand" + runMode="AS_ALIAS" rc="0"> + <arg>4</arg> + <arg>/</arg> + <arg>2</arg> + <output>2 +</output> + </testSpec> + <testSpec title="expr 1 + 2 * 2" command="org.jnode.shell.command.posix.ExprCommand" + runMode="AS_ALIAS" rc="0"> + <arg>1</arg> + <arg>+</arg> + <arg>2</arg> + <arg>*</arg> + <arg>2</arg> + <output>5 +</output> + </testSpec> + <testSpec title="expr ( 1 + 2 ) * 2" command="org.jnode.shell.command.posix.ExprCommand" + runMode="AS_ALIAS" rc="0"> + <arg>(</arg> + <arg>1</arg> + <arg>+</arg> + <arg>2</arg> + <arg>)</arg> + <arg>*</arg> + <arg>2</arg> + <output>6 +</output> + </testSpec> </testSet> \ No newline at end of file Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-02-17 14:52:18 UTC (rev 5042) @@ -46,8 +46,9 @@ @Override public int run() throws Exception { Properties props = new Properties(); - props.setProperty("TEMP_DIR", System.getProperty("java.io.tmpdir")); - tempScriptFile = new File(System.getProperty("java.io.tmpdir"), spec.getCommand()); + String tempDir = System.getProperty("java.io.tmpdir"); + props.setProperty("TEMP_DIR", tempDir); + tempScriptFile = new File(tempDir, spec.getCommand()); BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter(tempScriptFile)); Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-02-16 21:32:28 UTC (rev 5041) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-02-17 14:52:18 UTC (rev 5042) @@ -91,16 +91,16 @@ if (!emuInitialized) { throw new IllegalStateException("Emu not initialized"); } - if (!loadedPseudoPlugins.contains(className)) { - try { + try { + if (!loadedPseudoPlugins.contains(className)) { Class<?> clazz = Class.forName(className); clazz.newInstance(); - Method method = emuClass.getMethod("configurePluginCommands", String.class); - method.invoke(emuObject, pluginId); - } catch (Exception ex) { - throw new RuntimeException("Cannot configure plugin '" + pluginId + "'", ex); + loadedPseudoPlugins.add(className); } - loadedPseudoPlugins.add(className); + Method method = emuClass.getMethod("configurePlugin", String.class); + method.invoke(emuObject, pluginId); + } catch (Exception ex) { + throw new RuntimeException("Cannot configure plugin '" + pluginId + "'", ex); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-18 10:45:05
|
Revision: 5047 http://jnode.svn.sourceforge.net/jnode/?rev=5047&view=rev Author: lsantha Date: 2009-02-18 10:45:00 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Removed unused and outdated plugins. Modified Paths: -------------- trunk/all/build.xml trunk/all/conf/default-plugin-list.xml trunk/core/descriptors/org.classpath.core.xml trunk/net/descriptors/com.jcraft.jsch.xml trunk/net/descriptors/org.jnode.test.net.xml Removed Paths: ------------- trunk/core/descriptors/crypto-security.xml trunk/core/lib/gnu-crypto.jar trunk/core/lib/javax-crypto.jar Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2009-02-17 19:54:00 UTC (rev 5046) +++ trunk/all/build.xml 2009-02-18 10:45:00 UTC (rev 5047) @@ -83,9 +83,6 @@ <property name="junit4.jar" value="${root.dir}/distr/lib/junit-4.1.jar"/> <property name="log4j.jar" value="${root.dir}/core/lib/log4j-1.2.8.jar"/> - <property name="gnu-crypto.jar" value="${root.dir}/core/lib/gnu-crypto.jar"/> - <property name="javax-crypto.jar" value="${root.dir}/core/lib/javax-crypto.jar"/> - <!-- property name="javax-security.jar" value="${root.dir}/core/lib/javax-security.jar" / --> <property name="beanshell.jar" value="${root.dir}/shell/lib/bsh-2.0b5.jar"/> <property name="js.jar" value="${root.dir}/shell/lib/rhino1.6r5-jsr223.jar"/> @@ -120,8 +117,6 @@ <pathelement location="${asm-util.jar}"/> <pathelement location="${cglib.jar}"/> <pathelement location="${log4j.jar}"/> - <pathelement location="${gnu-crypto.jar}"/> - <pathelement location="${javax-crypto.jar}"/> <pathelement location="${basedir}/conf"/> <pathelement location="${beanshell.jar}"/> <pathelement location="${js.jar}"/> @@ -252,8 +247,6 @@ <libalias name="commons-net-1.1.0.jar" alias="${commons-net.jar}"/> <libalias name="dnsjava-1.6.6.jar" alias="${dnsjava.jar}"/> <libalias name="jsch-0.1.24.jar" alias="${jsch.jar}"/> - <libalias name="gnu-crypto.jar" alias="${gnu-crypto.jar}"/> - <libalias name="javax-crypto.jar" alias="${javax-crypto.jar}"/> <libalias name="log4j.jar" alias="${log4j.jar}"/> <libalias name="beanshell.jar" alias="${beanshell.jar}"/> <libalias name="nanoxml-java.jar" alias="${nanoxml-java.jar}"/> Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2009-02-17 19:54:00 UTC (rev 5046) +++ trunk/all/conf/default-plugin-list.xml 2009-02-18 10:45:00 UTC (rev 5047) @@ -153,7 +153,6 @@ <plugin id="org.jnode.net.nfs"/> <plugin id="com.jcraft.jsch"/> - <plugin id="crypto-security"/> <plugin id="org.jnode.protocol"/> <plugin id="org.jnode.protocol.ftp"/> Deleted: trunk/core/descriptors/crypto-security.xml =================================================================== --- trunk/core/descriptors/crypto-security.xml 2009-02-17 19:54:00 UTC (rev 5046) +++ trunk/core/descriptors/crypto-security.xml 2009-02-18 10:45:00 UTC (rev 5047) @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plugin SYSTEM "jnode.dtd"> - -<plugin id="crypto-security" - name="GNU-Crypto classes" - version="2.0.1" - provider-name="http://www.gnu.org/software/gnu-crypto" - license-name="GPL + Library Exception" - license-url="http://www.gnu.org/software/gnu-crypto/"> - - <runtime> - <library name="gnu-crypto.jar"> - <export name="*"/> - </library> - <library name="javax-crypto.jar"> - <export name="*"/> - </library> - </runtime> - -</plugin> \ No newline at end of file Modified: trunk/core/descriptors/org.classpath.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.core.xml 2009-02-17 19:54:00 UTC (rev 5046) +++ trunk/core/descriptors/org.classpath.core.xml 2009-02-18 10:45:00 UTC (rev 5047) @@ -169,6 +169,7 @@ <export name="javax.xml.stream.util.*"/> <export name="javax.crypto.*"/> + <export name="javax.crypto.interfaces.*"/> <export name="javax.crypto.spec.*"/> <export name="javax.security.auth.AuthPermission"/> <export name="javax.security.auth.Destroyable"/> Deleted: trunk/core/lib/gnu-crypto.jar =================================================================== (Binary files differ) Deleted: trunk/core/lib/javax-crypto.jar =================================================================== (Binary files differ) Modified: trunk/net/descriptors/com.jcraft.jsch.xml =================================================================== --- trunk/net/descriptors/com.jcraft.jsch.xml 2009-02-17 19:54:00 UTC (rev 5046) +++ trunk/net/descriptors/com.jcraft.jsch.xml 2009-02-18 10:45:00 UTC (rev 5047) @@ -10,7 +10,7 @@ license-url="http://www.jcraft.com/jsch/LICENSE.txt"> <requires> - <import plugin="crypto-security"/> + <import plugin="org.classpath.ext.security"/> </requires> Modified: trunk/net/descriptors/org.jnode.test.net.xml =================================================================== --- trunk/net/descriptors/org.jnode.test.net.xml 2009-02-17 19:54:00 UTC (rev 5046) +++ trunk/net/descriptors/org.jnode.test.net.xml 2009-02-18 10:45:00 UTC (rev 5047) @@ -8,7 +8,6 @@ provider-name="JNode.org"> <requires> - <import plugin="crypto-security"/> <import plugin="com.jcraft.jsch"/> </requires> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-18 10:51:49
|
Revision: 5048 http://jnode.svn.sourceforge.net/jnode/?rev=5048&view=rev Author: lsantha Date: 2009-02-18 10:51:38 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Fixed IDEA project files. Modified Paths: -------------- trunk/builder/builder.iml trunk/distr/distr.iml trunk/shell/shell.iml Modified: trunk/builder/builder.iml =================================================================== --- trunk/builder/builder.iml 2009-02-18 10:45:00 UTC (rev 5047) +++ trunk/builder/builder.iml 2009-02-18 10:51:38 UTC (rev 5048) @@ -111,20 +111,20 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module" module-name="fs" /> <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/nanoxml-2.2.3.jar!/" /> + <root url="jar://$MODULE_DIR$/../core/lib/ant.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> - <orderEntry type="module" module-name="fs" /> <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/../core/lib/ant.jar!/" /> + <root url="jar://$MODULE_DIR$/../shell/lib/nanoxml-2.2.3.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> Modified: trunk/distr/distr.iml =================================================================== --- trunk/distr/distr.iml 2009-02-18 10:45:00 UTC (rev 5047) +++ trunk/distr/distr.iml 2009-02-18 10:51:38 UTC (rev 5048) @@ -20,15 +20,6 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/../../../../hda6/ext/devel/jnode/shell/lib/bsh-2.0b5.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> - </orderEntry> - <orderEntry type="module-library"> - <library> - <CLASSES> <root url="file://$MODULE_DIR$/lib" /> </CLASSES> <JAVADOC /> Modified: trunk/shell/shell.iml =================================================================== --- trunk/shell/shell.iml 2009-02-18 10:45:00 UTC (rev 5047) +++ trunk/shell/shell.iml 2009-02-18 10:51:38 UTC (rev 5048) @@ -26,7 +26,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/../builder/lib/nanoxml-2.2.3.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/nanoxml-2.2.3.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-02-24 12:11:14
|
Revision: 5061 http://jnode.svn.sourceforge.net/jnode/?rev=5061&view=rev Author: crawley Date: 2009-02-24 12:11:10 +0000 (Tue, 24 Feb 2009) Log Message: ----------- Moving 'cat' to Shell project. It is no more a file system command than (say) 'grep' or 'test'. Modified Paths: -------------- trunk/fs/descriptors/org.jnode.fs.command.xml trunk/shell/descriptors/org.jnode.shell.command.xml Added Paths: ----------- trunk/shell/src/shell/org/jnode/shell/command/CatCommand.java Removed Paths: ------------- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java Modified: trunk/fs/descriptors/org.jnode.fs.command.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.command.xml 2009-02-23 14:55:27 UTC (rev 5060) +++ trunk/fs/descriptors/org.jnode.fs.command.xml 2009-02-24 12:11:10 UTC (rev 5061) @@ -20,7 +20,6 @@ </runtime> <extension point="org.jnode.shell.aliases"> - <alias name="cat" class="org.jnode.fs.command.CatCommand"/> <alias name="cd" class="org.jnode.fs.command.CdCommand" internal="yes"/> <alias name="cp" class="org.jnode.fs.command.CpCommand"/> <alias name="del" class="org.jnode.fs.command.DeleteCommand"/> @@ -37,18 +36,6 @@ </extension> <extension point="org.jnode.shell.syntaxes"> - <syntax alias="cat"> - <empty description="copy standard input to standard output"/> - <sequence description="fetch and concatenate urls to standard output"> - <option argLabel="urls" shortName="u" longName="urls"/> - <repeat minCount="1"> - <argument argLabel="url"/> - </repeat> - </sequence> - <repeat minCount="1" description="concatenate files to standard output"> - <argument argLabel="file"/> - </repeat> - </syntax> <syntax alias="cd"> <empty description="change the current directory to the 'user.home' directory"/> <argument argLabel="directory" description="change the current directory to 'directory'"/> Deleted: trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2009-02-23 14:55:27 UTC (rev 5060) +++ trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2009-02-24 12:11:10 UTC (rev 5061) @@ -1,164 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.fs.command; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.net.URL; - -import org.jnode.shell.AbstractCommand; -import org.jnode.shell.syntax.Argument; -import org.jnode.shell.syntax.FileArgument; -import org.jnode.shell.syntax.FlagArgument; -import org.jnode.shell.syntax.URLArgument; - -/** - * Read files or network resources and write the concatenation to standard output. If - * no filenames or URIs are provided, copy standard input to standard output. Data is - * copied byte-wise. - * <p> - * If any file or URL cannot be opened, it is skipped and we (eventually) set a non-zero - * return code. If we get an IOException reading or writing data, we allow it to propagate. - * - * @author epr - * @author Andreas H\u00e4nel - * @author cr...@jn... - * @author Fabien DUMINY (fd...@jn...) - */ -public class CatCommand extends AbstractCommand { - - private final FileArgument ARG_FILE = - new FileArgument("file", Argument.OPTIONAL | Argument.MULTIPLE | Argument.EXISTING, - "the files to be concatenated"); - - private final URLArgument ARG_URL = - new URLArgument("url", Argument.OPTIONAL | Argument.MULTIPLE | Argument.EXISTING, - "the urls to be concatenated"); - - private final FlagArgument FLAG_URLS = - new FlagArgument("urls", Argument.OPTIONAL, "If set, arguments will be urls"); - - private PrintWriter err; - - public CatCommand() { - super("Concatenate the contents of files, urls or standard input to standard output"); - registerArguments(ARG_FILE, ARG_URL, FLAG_URLS); - } - - private static final int BUFFER_SIZE = 8192; - - - public static void main(String[] args) throws Exception { - new CatCommand().execute(args); - } - - public void execute() throws IOException { - this.err = getError().getPrintWriter(); - OutputStream out = getOutput().getOutputStream(); - File[] files = ARG_FILE.getValues(); - URL[] urls = ARG_URL.getValues(); - - boolean ok = true; - if (urls != null && urls.length > 0) { - for (URL url : urls) { - InputStream is = null; - try { - is = url.openStream(); - } catch (IOException ex) { - err.println("Can't fetch url '" + url + "': " + ex.getLocalizedMessage()); - ok = false; - } - if (is != null) { - try { - process(is, out); - } finally { - try { - is.close(); - } catch (IOException ex) { - /* ignore */ - } - } - } - } - } else if (files != null && files.length > 0) { - for (File file : files) { - InputStream is = null; - try { - is = openFile(file); - if (is == null) { - ok = false; - } else { - process(is, out); - } - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - /* ignore */ - } - } - } - } - } else { - process(getInput().getInputStream(), out); - } - out.flush(); - if (!ok) { - exit(1); - } - } - - /** - * Copy all of stream 'in' to stream 'out' - * @param in - * @param out - * @throws IOException - */ - private void process(InputStream in, OutputStream out) throws IOException { - int len; - final byte[] buf = new byte[BUFFER_SIZE]; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - } - - /** - * Attempt to open a file, writing an error message on failure. - * @param fname the filename of the file to be opened - * @return An open stream, or <code>null</code>. - * @throws FileNotFoundException - */ - private InputStream openFile(File file) throws FileNotFoundException { - try { - return new FileInputStream(file); - } catch (IOException ex) { - err.println("Cannot open file '" + file + "': " + ex.getLocalizedMessage()); - return null; - } - } - -} Modified: trunk/shell/descriptors/org.jnode.shell.command.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.xml 2009-02-23 14:55:27 UTC (rev 5060) +++ trunk/shell/descriptors/org.jnode.shell.command.xml 2009-02-24 12:11:10 UTC (rev 5061) @@ -20,6 +20,7 @@ <extension point="org.jnode.shell.aliases"> <alias name="alias" class="org.jnode.shell.command.AliasCommand"/> <alias name="bindkeys" class="org.jnode.shell.command.BindKeysCommand"/> + <alias name="cat" class="org.jnode.shell.command.CatCommand"/> <alias name="class" class="org.jnode.shell.command.ClassCommand"/> <alias name="classpath" class="org.jnode.shell.command.ClasspathCommand" internal="yes"/> <alias name="compile" class="org.jnode.shell.command.CompileCommand"/> @@ -84,6 +85,18 @@ </repeat> </sequence> </syntax> + <syntax alias="cat"> + <empty description="copy standard input to standard output"/> + <sequence description="fetch and concatenate urls to standard output"> + <option argLabel="urls" shortName="u" longName="urls"/> + <repeat minCount="1"> + <argument argLabel="url"/> + </repeat> + </sequence> + <repeat minCount="1" description="concatenate files to standard output"> + <argument argLabel="file"/> + </repeat> + </syntax> <syntax alias="class" description="Show details of a Java class"> <argument argLabel="className"/> </syntax> Added: trunk/shell/src/shell/org/jnode/shell/command/CatCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/CatCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/CatCommand.java 2009-02-24 12:11:10 UTC (rev 5061) @@ -0,0 +1,164 @@ +/* + * $Id: CatCommand.java 4975 2009-02-02 08:30:52Z lsantha $ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.net.URL; + +import org.jnode.shell.AbstractCommand; +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.FlagArgument; +import org.jnode.shell.syntax.URLArgument; + +/** + * Read files or network resources and write the concatenation to standard output. If + * no filenames or URIs are provided, copy standard input to standard output. Data is + * copied byte-wise. + * <p> + * If any file or URL cannot be opened, it is skipped and we (eventually) set a non-zero + * return code. If we get an IOException reading or writing data, we allow it to propagate. + * + * @author epr + * @author Andreas H\u00e4nel + * @author cr...@jn... + * @author Fabien DUMINY (fd...@jn...) + */ +public class CatCommand extends AbstractCommand { + + private final FileArgument ARG_FILE = + new FileArgument("file", Argument.OPTIONAL | Argument.MULTIPLE | Argument.EXISTING, + "the files to be concatenated"); + + private final URLArgument ARG_URL = + new URLArgument("url", Argument.OPTIONAL | Argument.MULTIPLE | Argument.EXISTING, + "the urls to be concatenated"); + + private final FlagArgument FLAG_URLS = + new FlagArgument("urls", Argument.OPTIONAL, "If set, arguments will be urls"); + + private PrintWriter err; + + public CatCommand() { + super("Concatenate the contents of files, urls or standard input to standard output"); + registerArguments(ARG_FILE, ARG_URL, FLAG_URLS); + } + + private static final int BUFFER_SIZE = 8192; + + + public static void main(String[] args) throws Exception { + new CatCommand().execute(args); + } + + public void execute() throws IOException { + this.err = getError().getPrintWriter(); + OutputStream out = getOutput().getOutputStream(); + File[] files = ARG_FILE.getValues(); + URL[] urls = ARG_URL.getValues(); + + boolean ok = true; + if (urls != null && urls.length > 0) { + for (URL url : urls) { + InputStream is = null; + try { + is = url.openStream(); + } catch (IOException ex) { + err.println("Can't fetch url '" + url + "': " + ex.getLocalizedMessage()); + ok = false; + } + if (is != null) { + try { + process(is, out); + } finally { + try { + is.close(); + } catch (IOException ex) { + /* ignore */ + } + } + } + } + } else if (files != null && files.length > 0) { + for (File file : files) { + InputStream is = null; + try { + is = openFile(file); + if (is == null) { + ok = false; + } else { + process(is, out); + } + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException ex) { + /* ignore */ + } + } + } + } + } else { + process(getInput().getInputStream(), out); + } + out.flush(); + if (!ok) { + exit(1); + } + } + + /** + * Copy all of stream 'in' to stream 'out' + * @param in + * @param out + * @throws IOException + */ + private void process(InputStream in, OutputStream out) throws IOException { + int len; + final byte[] buf = new byte[BUFFER_SIZE]; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + } + + /** + * Attempt to open a file, writing an error message on failure. + * @param fname the filename of the file to be opened + * @return An open stream, or <code>null</code>. + * @throws FileNotFoundException + */ + private InputStream openFile(File file) throws FileNotFoundException { + try { + return new FileInputStream(file); + } catch (IOException ex) { + err.println("Cannot open file '" + file + "': " + ex.getLocalizedMessage()); + return null; + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-26 21:53:25
|
Revision: 5066 http://jnode.svn.sourceforge.net/jnode/?rev=5066&view=rev Author: lsantha Date: 2009-02-26 21:53:20 +0000 (Thu, 26 Feb 2009) Log Message: ----------- OpenJDK integration and cleanups. Modified Paths: -------------- trunk/all/build.xml trunk/all/conf/default-plugin-list.xml trunk/core/descriptors/org.classpath.core.xml trunk/core/descriptors/org.classpath.ext.core.xml trunk/core/descriptors/org.classpath.ext.management.xml trunk/core/descriptors/org.classpath.ext.xml.xml Added Paths: ----------- trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml trunk/core/descriptors/org.classpath.ext.xml.ws.xml Removed Paths: ------------- trunk/core/descriptors/mx4j.xml trunk/core/lib/mx4j-remote.jar trunk/core/lib/mx4j.jar Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/all/build.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -44,9 +44,6 @@ <property name="jnode-mmtk-ms.jar" value="${root.dir}/core/build/classes-plan/org.jnode.vm.memmgr.mmtk.ms"/> <property name="jnode-mmtk-nogc.jar" value="${root.dir}/core/build/classes-plan/org.jnode.vm.memmgr.mmtk.nogc"/> - <property name="mx4j.jar" value="${root.dir}/core/lib/mx4j.jar"/> - <property name="mx4j-remote.jar" value="${root.dir}/core/lib/mx4j-remote.jar"/> - <property name="ant.jar" value="${root.dir}/core/lib/ant.jar"/> <property name="ant-launcher.jar" value="${root.dir}/core/lib/ant-launcher.jar"/> <property name="commons-net.jar" value="${root.dir}/core/lib/commons-net-1.1.0.jar"/> @@ -144,8 +141,6 @@ <pathelement location="${thinlet.jar}"/> <pathelement location="${jnode-textui.jar}"/> <pathelement location="${bcel-5.1.jar}"/> - <pathelement location="${mx4j.jar}"/> - <pathelement location="${mx4j-remote.jar}"/> <path refid="cp"/> </path> @@ -241,8 +236,6 @@ <libalias name="jnode-mmtk-nogc.jar" alias="${jnode-mmtk-nogc.jar}"/> <libalias name="mmtk.jar" alias="${mmtk.jar}"/> - <libalias name="mx4j.jar" alias="${mx4j.jar}"/> - <libalias name="mx4j-remote.jar" alias="${mx4j-remote.jar}"/> <libalias name="commons-net-1.1.0.jar" alias="${commons-net.jar}"/> <libalias name="dnsjava-1.6.6.jar" alias="${dnsjava.jar}"/> @@ -251,7 +244,6 @@ <libalias name="beanshell.jar" alias="${beanshell.jar}"/> <libalias name="nanoxml-java.jar" alias="${nanoxml-java.jar}"/> <libalias name="js.jar" alias="${js.jar}"/> - <libalias name="lw.jar" alias="${lw.jar}"/> <libalias name="thinlet.jar" alias="${thinlet.jar}"/> <libalias name="junit.jar" alias="${junit.jar}"/> @@ -266,9 +258,7 @@ <libalias name="jfunc.jar" alias="${jfunc.jar}"/> <libalias name="ant.jar" alias="${ant.jar}"/> - <libalias name="ant-commons-net.jar" alias="${ant-commons-net.jar}"/> <libalias name="ant-launcher.jar" alias="${ant-launcher.jar}"/> - <libalias name="ant-trax.jar" alias="${ant-trax.jar}"/> <libalias name="edtftpj.jar" alias="${edtftpj.jar}"/> <libalias name="jcifs.jar" alias="${jcifs.jar}"/> <libalias name="ejc.jar" alias="${ejc.jar}"/> Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/all/conf/default-plugin-list.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -29,7 +29,6 @@ <plugin id="org.classpath.ext.sql"/> <plugin id="org.classpath.ext.security"/> <plugin id="org.classpath.tools"/> - <plugin id="mx4j"/> <plugin id="org.apache.jakarta.commons.net"/> <plugin id="org.xbill.dns"/> Deleted: trunk/core/descriptors/mx4j.xml =================================================================== --- trunk/core/descriptors/mx4j.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/core/descriptors/mx4j.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plugin SYSTEM "jnode.dtd"> - -<fragment id="mx4j" - name="MX4J Management Extensions" - version="3.0.1" - plugin-id="rt" - plugin-version="@VERSION@" - provider-name="mx4j.org" - provider-url="http://mx4j.org" - license-name="apache"> - - <runtime> - <library name="mx4j.jar"> - <export name="javax.management.*"/> - <export name="javax.management.loading.*"/> - <export name="javax.management.modelmbean.*"/> - <export name="javax.management.monitor.*"/> - <export name="javax.management.openmbean.*"/> - <export name="javax.management.relation.*"/> - <export name="javax.management.timer.*"/> - - <export name="mx4j.*"/> - <export name="mx4j.loading.*"/> - <export name="mx4j.log.*"/> - <export name="mx4j.monitor.*"/> - <export name="mx4j.persist.*"/> - <export name="mx4j.server.*"/> - <export name="mx4j.server.interceptor.*"/> - <export name="mx4j.timer.*"/> - <export name="mx4j.util.*"/> - </library> - - <library name="mx4j-remote.jar"> - <export name="javax.management.remote.*"/> - <export name="javax.management.remote.rmi.*"/> - - <export name="mx4j.*"/> - <export name="mx4j.log.*"/> - <export name="mx4j.remote.*"/> - <export name="mx4j.remote.provider.*"/> - <export name="mx4j.remote.provider.iiop.*"/> - <export name="mx4j.remote.provider.rmi.*"/> - <export name="mx4j.remote.resolver.iiop.*"/> - <export name="mx4j.remote.resolver.rmi.*"/> - <export name="mx4j.remote.rmi.*"/> - <export name="mx4j.util.*"/> - <export name="org.omg.stub.javax.management.remote.rmi.*"/> - </library> - </runtime> - -</fragment> Modified: trunk/core/descriptors/org.classpath.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.core.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/core/descriptors/org.classpath.core.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -100,7 +100,6 @@ <export name="gnu.java.security.util.*"/> <export name="gnu.java.util.*"/> - <export name="gnu.java.util.jar.*"/> <export name="java.awt.AWTPermission"/> <export name="java.beans.ChangeListenerMap" /> Modified: trunk/core/descriptors/org.classpath.ext.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.core.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/core/descriptors/org.classpath.ext.core.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -58,7 +58,6 @@ <export name="java.awt.print.*"/> <export name="java.beans.*"/> <export name="java.beans.beancontext.*"/> - <export name="java.lang.management.*"/> <export name="java.rmi.*"/> <export name="java.rmi.activation.*"/> <export name="java.rmi.dgc.*"/> @@ -88,8 +87,6 @@ <export name="javax.activity.*"/> <export name="javax.annotation.*"/> <export name="javax.annotation.processing.*"/> - <export name="javax.jws.*"/> - <export name="javax.jws.soap.*"/> <export name="javax.lang.model.*"/> <export name="javax.lang.model.element.*"/> <export name="javax.lang.model.type.*"/> Modified: trunk/core/descriptors/org.classpath.ext.management.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.management.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/core/descriptors/org.classpath.ext.management.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -11,8 +11,30 @@ license-name="classpath"> <runtime> - <library name="jnode-core.jar"> + <library name="jnode-core.jar"> + <export name="com.sun.management.*"/> + <export name="com.sun.jmx.defaults.*"/> + <export name="com.sun.jmx.interceptor.*"/> + <export name="com.sun.jmx.mbeanserver.*"/> + <export name="com.sun.jmx.remote.internal.*"/> + <export name="com.sun.jmx.remote.protocol.iiop.*"/> + <export name="com.sun.jmx.remote.protocol.rmi.*"/> + <export name="com.sun.jmx.remote.security.*"/> + <export name="com.sun.jmx.remote.util.*"/> + <export name="java.lang.management.*"/> + <export name="javax.management.*"/> + <export name="javax.management.loading.*"/> + <export name="javax.management.modelmbean.*"/> + <export name="javax.management.monitor.*"/> <export name="javax.management.openmbean.*"/> + <export name="javax.management.relation.*"/> + <export name="javax.management.remote.*"/> + <export name="javax.management.remote.rmi.*"/> + <export name="javax.management.timer.*"/> + <export name="sun.management.*"/> + <export name="sun.management.counter.*"/> + <export name="sun.management.counter.perf.*"/> + <export name="sun.management.jmxremote.*"/> </library> </runtime> Added: trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml (rev 0) +++ trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<fragment id="org.classpath.ext.xml.ws.tools" + name="Classpath javax.xml classes" + version="@VERSION@" + plugin-id="rt" + plugin-version="@VERSION@" + provider-name="Classpath" + provider-url="http://classpath.org" + license-name="classpath"> + + <runtime> + <library name="jnode-core.jar"> + <export name="com.sun.codemodel.internal.*"/> + <export name="com.sun.codemodel.internal.fmt.*"/> + <export name="com.sun.codemodel.internal.util.*"/> + <export name="com.sun.codemodel.internal.writer.*"/> + <export name="com.sun.tools.internal.jxc.*"/> + <export name="com.sun.tools.internal.jxc.apt.*"/> + <export name="com.sun.tools.internal.jxc.gen.config.*"/> + <export name="com.sun.tools.internal.jxc.model.nav.*"/> + <export name="com.sun.tools.internal.ws.*"/> + <export name="com.sun.tools.internal.ws.api.*"/> + <export name="com.sun.tools.internal.ws.api.wsdl.*"/> + <export name="com.sun.tools.internal.ws.processor.*"/> + <export name="com.sun.tools.internal.ws.processor.generator.*"/> + <export name="com.sun.tools.internal.ws.processor.model.*"/> + <export name="com.sun.tools.internal.ws.processor.model.exporter.*"/> + <export name="com.sun.tools.internal.ws.processor.model.java.*"/> + <export name="com.sun.tools.internal.ws.processor.model.jaxb.*"/> + <export name="com.sun.tools.internal.ws.processor.modeler.*"/> + <export name="com.sun.tools.internal.ws.processor.modeler.annotation.*"/> + <export name="com.sun.tools.internal.ws.processor.modeler.wsdl.*"/> + <export name="com.sun.tools.internal.ws.processor.util.*"/> + <export name="com.sun.tools.internal.ws.resources.*"/> + <export name="com.sun.tools.internal.ws.spi.*"/> + <export name="com.sun.tools.internal.ws.util.*"/> + <export name="com.sun.tools.internal.ws.util.xml.*"/> + <export name="com.sun.tools.internal.ws.wscompile.*"/> + <export name="com.sun.tools.internal.ws.wsdl.*"/> + <export name="com.sun.tools.internal.ws.wsdl.document.*"/> + <export name="com.sun.tools.internal.ws.wsdl.document.http.*"/> + <export name="com.sun.tools.internal.ws.wsdl.document.jaxws.*"/> + <export name="com.sun.tools.internal.ws.wsdl.document.mime.*"/> + <export name="com.sun.tools.internal.ws.wsdl.document.schema.*"/> + <export name="com.sun.tools.internal.ws.wsdl.document.soap.*"/> + <export name="com.sun.tools.internal.ws.wsdl.framework.*"/> + <export name="com.sun.tools.internal.ws.wsdl.parser.*"/> + <export name="com.sun.tools.internal.xjc.*"/> + <export name="com.sun.tools.internal.xjc.addon.at_generated.*"/> + <export name="com.sun.tools.internal.xjc.addon.code_injector.*"/> + <export name="com.sun.tools.internal.xjc.addon.episode.*"/> + <export name="com.sun.tools.internal.xjc.addon.locator.*"/> + <export name="com.sun.tools.internal.xjc.addon.sync.*"/> + <export name="com.sun.tools.internal.xjc.api.*"/> + <export name="com.sun.tools.internal.xjc.api.impl.j2s.*"/> + <export name="com.sun.tools.internal.xjc.api.impl.s2j.*"/> + <export name="com.sun.tools.internal.xjc.api.util.*"/> + <export name="com.sun.tools.internal.xjc.generator.*"/> + <export name="com.sun.tools.internal.xjc.generator.annotation.ri.*"/> + <export name="com.sun.tools.internal.xjc.generator.annotation.spec.*"/> + <export name="com.sun.tools.internal.xjc.generator.bean.*"/> + <export name="com.sun.tools.internal.xjc.generator.bean.field.*"/> + <export name="com.sun.tools.internal.xjc.generator.util.*"/> + <export name="com.sun.tools.internal.xjc.model.*"/> + <export name="com.sun.tools.internal.xjc.model.nav.*"/> + <export name="com.sun.tools.internal.xjc.outline.*"/> + <export name="com.sun.tools.internal.xjc.reader.*"/> + <export name="com.sun.tools.internal.xjc.reader.dtd.*"/> + <export name="com.sun.tools.internal.xjc.reader.dtd.bindinfo.*"/> + <export name="com.sun.tools.internal.xjc.reader.gbind.*"/> + <export name="com.sun.tools.internal.xjc.reader.internalizer.*"/> + <export name="com.sun.tools.internal.xjc.reader.relaxng.*"/> + <export name="com.sun.tools.internal.xjc.reader.xmlschema.*"/> + <export name="com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.*"/> + <export name="com.sun.tools.internal.xjc.reader.xmlschema.ct.*"/> + <export name="com.sun.tools.internal.xjc.reader.xmlschema.parser.*"/> + <export name="com.sun.tools.internal.xjc.runtime.*"/> + <export name="com.sun.tools.internal.xjc.util.*"/> + <export name="com.sun.tools.internal.xjc.writer.*"/> + </library> + + </runtime> + <extension point="org.jnode.shell.aliases"> + <alias name="xjc" class="com.sun.tools.internal.xjc.Driver"/> + <alias name="schemagen" class="com.sun.tools.internal.jxc.SchemaGenerator"/> + <alias name="wsgen" class="com.sun.tools.internal.ws.WsGen"/> + <alias name="wsimport" class="com.sun.tools.internal.ws.WsImport"/> + </extension> + + <extension point="org.jnode.security.permissions"> + <permission class="java.lang.RuntimePermission" name="exitVM"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.util.PropertyPermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.util.PropertyPermission" name="*" actions="read"/> + <permission class="java.lang.RuntimePermission" name="getProtectionDomain"/> + <permission class="java.lang.RuntimePermission" name="createClassLoader"/> + <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> + <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> + <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> + <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> + <permission class="java.net.SocketPermission" name="*" actions="resolve"/> + <permission class="java.net.SocketPermission" name="*:0-" actions="connect,resolve"/> + <permission class="java.lang.RuntimePermission" name="writeFileDescriptor"/> + <permission class="java.lang.RuntimePermission" name="readFileDescriptor"/> + </extension> + +</fragment> Copied: trunk/core/descriptors/org.classpath.ext.xml.ws.xml (from rev 5064, trunk/core/descriptors/org.classpath.ext.xml.xml) =================================================================== --- trunk/core/descriptors/org.classpath.ext.xml.ws.xml (rev 0) +++ trunk/core/descriptors/org.classpath.ext.xml.ws.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<fragment id="org.classpath.ext.xml.ws" + name="Classpath javax.xml classes" + version="@VERSION@" + plugin-id="rt" + plugin-version="@VERSION@" + provider-name="Classpath" + provider-url="http://classpath.org" + license-name="classpath"> + + <runtime> + <library name="jnode-core.jar"> + <export name="com.sun.activation.registries.*"/> + <export name="com.sun.istack.internal.*"/> + <export name="com.sun.istack.internal.tools.*"/> + <export name="com.sun.istack.internal.ws.*"/> + <export name="com.sun.xml.internal.bind.*"/> + <export name="com.sun.xml.internal.bind.annotation.*"/> + <export name="com.sun.xml.internal.bind.api.*"/> + <export name="com.sun.xml.internal.bind.api.impl.*"/> + <export name="com.sun.xml.internal.bind.marshaller.*"/> + <export name="com.sun.xml.internal.bind.unmarshaller.*"/> + <export name="com.sun.xml.internal.bind.util.*"/> + <export name="com.sun.xml.internal.bind.v2.*"/> + <export name="com.sun.xml.internal.bind.v2.bytecode.*"/> + <export name="com.sun.xml.internal.bind.v2.model.annotation.*"/> + <export name="com.sun.xml.internal.bind.v2.model.core.*"/> + <export name="com.sun.xml.internal.bind.v2.model.impl.*"/> + <export name="com.sun.xml.internal.bind.v2.model.nav.*"/> + <export name="com.sun.xml.internal.bind.v2.model.runtime.*"/> + <export name="com.sun.xml.internal.bind.v2.runtime.*"/> + <export name="com.sun.xml.internal.bind.v2.runtime.output.*"/> + <export name="com.sun.xml.internal.bind.v2.runtime.property.*"/> + <export name="com.sun.xml.internal.bind.v2.runtime.reflect.*"/> + <export name="com.sun.xml.internal.bind.v2.runtime.reflect.opt.*"/> + <export name="com.sun.xml.internal.bind.v2.runtime.unmarshaller.*"/> + <export name="com.sun.xml.internal.bind.v2.schemagen.*"/> + <export name="com.sun.xml.internal.bind.v2.schemagen.episode.*"/> + <export name="com.sun.xml.internal.bind.v2.schemagen.xmlschema.*"/> + <export name="com.sun.xml.internal.bind.v2.util.*"/> + <export name="com.sun.xml.internal.dtdparser.*"/> + <export name="com.sun.xml.internal.dtdparser.resources.*"/> + <export name="com.sun.xml.internal.fastinfoset.*"/> + <export name="com.sun.xml.internal.fastinfoset.algorithm.*"/> + <export name="com.sun.xml.internal.fastinfoset.alphabet.*"/> + <export name="com.sun.xml.internal.fastinfoset.dom.*"/> + <export name="com.sun.xml.internal.fastinfoset.org.apache.xerces.util.*"/> + <export name="com.sun.xml.internal.fastinfoset.resources.*"/> + <export name="com.sun.xml.internal.fastinfoset.sax.*"/> + <export name="com.sun.xml.internal.fastinfoset.stax.*"/> + <export name="com.sun.xml.internal.fastinfoset.stax.events.*"/> + <export name="com.sun.xml.internal.fastinfoset.stax.factory.*"/> + <export name="com.sun.xml.internal.fastinfoset.stax.util.*"/> + <export name="com.sun.xml.internal.fastinfoset.tools.*"/> + <export name="com.sun.xml.internal.fastinfoset.util.*"/> + <export name="com.sun.xml.internal.fastinfoset.vocab.*"/> + <export name="com.sun.xml.internal.messaging.saaj.*"/> + <export name="com.sun.xml.internal.messaging.saaj.client.p2p.*"/> + <export name="com.sun.xml.internal.messaging.saaj.packaging.mime.*"/> + <export name="com.sun.xml.internal.messaging.saaj.packaging.mime.internet.*"/> + <export name="com.sun.xml.internal.messaging.saaj.packaging.mime.util.*"/> + <export name="com.sun.xml.internal.messaging.saaj.soap.*"/> + <export name="com.sun.xml.internal.messaging.saaj.soap.dynamic.*"/> + <export name="com.sun.xml.internal.messaging.saaj.soap.impl.*"/> + <export name="com.sun.xml.internal.messaging.saaj.soap.name.*"/> + <export name="com.sun.xml.internal.messaging.saaj.soap.ver1_1.*"/> + <export name="com.sun.xml.internal.messaging.saaj.soap.ver1_2.*"/> + <export name="com.sun.xml.internal.messaging.saaj.util.*"/> + <export name="com.sun.xml.internal.messaging.saaj.util.transform.*"/> + <export name="com.sun.xml.internal.org.jvnet.fastinfoset.*"/> + <export name="com.sun.xml.internal.org.jvnet.fastinfoset.sax.*"/> + <export name="com.sun.xml.internal.org.jvnet.fastinfoset.sax.helpers.*"/> + <export name="com.sun.xml.internal.org.jvnet.fastinfoset.stax.*"/> + <export name="com.sun.xml.internal.org.jvnet.staxex.*"/> + <export name="com.sun.xml.internal.rngom.ast.*"/> + <export name="com.sun.xml.internal.rngom.ast.builder.*"/> + <export name="com.sun.xml.internal.rngom.ast.om.*"/> + <export name="com.sun.xml.internal.rngom.ast.util.*"/> + <export name="com.sun.xml.internal.rngom.binary.*"/> + <export name="com.sun.xml.internal.rngom.binary.visitor.*"/> + <export name="com.sun.xml.internal.rngom.digested.*"/> + <export name="com.sun.xml.internal.rngom.dt.*"/> + <export name="com.sun.xml.internal.rngom.dt.builtin.*"/> + <export name="com.sun.xml.internal.rngom.nc.*"/> + <export name="com.sun.xml.internal.rngom.parse.*"/> + <export name="com.sun.xml.internal.rngom.parse.compact.*"/> + <export name="com.sun.xml.internal.rngom.parse.host.*"/> + <export name="com.sun.xml.internal.rngom.parse.xml.*"/> + <export name="com.sun.xml.internal.rngom.util.*"/> + <export name="com.sun.xml.internal.rngom.xml.sax.*"/> + <export name="com.sun.xml.internal.rngom.xml.util.*"/> + <export name="com.sun.xml.internal.stream.buffer.*"/> + <export name="com.sun.xml.internal.stream.buffer.sax.*"/> + <export name="com.sun.xml.internal.stream.buffer.stax.*"/> + <export name="com.sun.xml.internal.txw2.*"/> + <export name="com.sun.xml.internal.txw2.annotation.*"/> + <export name="com.sun.xml.internal.txw2.output.*"/> + <export name="com.sun.xml.internal.ws.*"/> + <export name="com.sun.xml.internal.ws.addressing.*"/> + <export name="com.sun.xml.internal.ws.addressing.model.*"/> + <export name="com.sun.xml.internal.ws.addressing.v200408.*"/> + <export name="com.sun.xml.internal.ws.api.*"/> + <export name="com.sun.xml.internal.ws.api.addressing.*"/> + <export name="com.sun.xml.internal.ws.api.client.*"/> + <export name="com.sun.xml.internal.ws.api.fastinfoset.*"/> + <export name="com.sun.xml.internal.ws.api.message.*"/> + <export name="com.sun.xml.internal.ws.api.message.stream.*"/> + <export name="com.sun.xml.internal.ws.api.model.*"/> + <export name="com.sun.xml.internal.ws.api.model.soap.*"/> + <export name="com.sun.xml.internal.ws.api.model.wsdl.*"/> + <export name="com.sun.xml.internal.ws.api.pipe.*"/> + <export name="com.sun.xml.internal.ws.api.pipe.helper.*"/> + <export name="com.sun.xml.internal.ws.api.server.*"/> + <export name="com.sun.xml.internal.ws.api.streaming.*"/> + <export name="com.sun.xml.internal.ws.api.wsdl.parser.*"/> + <export name="com.sun.xml.internal.ws.api.wsdl.writer.*"/> + <export name="com.sun.xml.internal.ws.binding.*"/> + <export name="com.sun.xml.internal.ws.client.*"/> + <export name="com.sun.xml.internal.ws.client.dispatch.*"/> + <export name="com.sun.xml.internal.ws.client.dispatch.impl.*"/> + <export name="com.sun.xml.internal.ws.client.sei.*"/> + <export name="com.sun.xml.internal.ws.developer.*"/> + <export name="com.sun.xml.internal.ws.encoding.*"/> + <export name="com.sun.xml.internal.ws.encoding.fastinfoset.*"/> + <export name="com.sun.xml.internal.ws.encoding.soap.*"/> + <export name="com.sun.xml.internal.ws.encoding.soap.streaming.*"/> + <export name="com.sun.xml.internal.ws.encoding.xml.*"/> + <export name="com.sun.xml.internal.ws.fault.*"/> + <export name="com.sun.xml.internal.ws.handler.*"/> + <export name="com.sun.xml.internal.ws.message.*"/> + <export name="com.sun.xml.internal.ws.message.jaxb.*"/> + <export name="com.sun.xml.internal.ws.message.saaj.*"/> + <export name="com.sun.xml.internal.ws.message.source.*"/> + <export name="com.sun.xml.internal.ws.message.stream.*"/> + <export name="com.sun.xml.internal.ws.model.*"/> + <export name="com.sun.xml.internal.ws.model.soap.*"/> + <export name="com.sun.xml.internal.ws.model.wsdl.*"/> + <export name="com.sun.xml.internal.ws.protocol.soap.*"/> + <export name="com.sun.xml.internal.ws.protocol.xml.*"/> + <export name="com.sun.xml.internal.ws.resources.*"/> + <export name="com.sun.xml.internal.ws.server.*"/> + <export name="com.sun.xml.internal.ws.server.provider.*"/> + <export name="com.sun.xml.internal.ws.server.sei.*"/> + <export name="com.sun.xml.internal.ws.spi.*"/> + <export name="com.sun.xml.internal.ws.streaming.*"/> + <export name="com.sun.xml.internal.ws.transport.*"/> + <export name="com.sun.xml.internal.ws.transport.http.*"/> + <export name="com.sun.xml.internal.ws.transport.http.client.*"/> + <export name="com.sun.xml.internal.ws.transport.http.server.*"/> + <export name="com.sun.xml.internal.ws.util.*"/> + <export name="com.sun.xml.internal.ws.util.exception.*"/> + <export name="com.sun.xml.internal.ws.util.localization.*"/> + <export name="com.sun.xml.internal.ws.util.pipe.*"/> + <export name="com.sun.xml.internal.ws.util.resources.*"/> + <export name="com.sun.xml.internal.ws.util.xml.*"/> + <export name="com.sun.xml.internal.ws.wsdl.*"/> + <export name="com.sun.xml.internal.ws.wsdl.parser.*"/> + <export name="com.sun.xml.internal.ws.wsdl.writer.*"/> + <export name="com.sun.xml.internal.ws.wsdl.writer.document.*"/> + <export name="com.sun.xml.internal.ws.wsdl.writer.document.http.*"/> + <export name="com.sun.xml.internal.ws.wsdl.writer.document.soap.*"/> + <export name="com.sun.xml.internal.ws.wsdl.writer.document.soap12.*"/> + <export name="com.sun.xml.internal.ws.wsdl.writer.document.xsd.*"/> + <export name="com.sun.xml.internal.xsom.*"/> + <export name="com.sun.xml.internal.xsom.impl.*"/> + <export name="com.sun.xml.internal.xsom.impl.parser.*"/> + <export name="com.sun.xml.internal.xsom.impl.parser.state.*"/> + <export name="com.sun.xml.internal.xsom.impl.scd.*"/> + <export name="com.sun.xml.internal.xsom.impl.util.*"/> + <export name="com.sun.xml.internal.xsom.parser.*"/> + <export name="com.sun.xml.internal.xsom.util.*"/> + <export name="com.sun.xml.internal.xsom.visitor.*"/> + <export name="javax.jws.*"/> + <export name="javax.jws.soap.*"/> + <export name="javax.xml.bind.*"/> + <export name="javax.xml.bind.annotation.*"/> + <export name="javax.xml.bind.annotation.adapters.*"/> + <export name="javax.xml.bind.attachment.*"/> + <export name="javax.xml.bind.helpers.*"/> + <export name="javax.xml.bind.util.*"/> + <export name="javax.xml.soap.*"/> + <export name="javax.xml.ws.*"/> + <export name="javax.xml.ws.handler.*"/> + <export name="javax.xml.ws.handler.soap.*"/> + <export name="javax.xml.ws.http.*"/> + <export name="javax.xml.ws.soap.*"/> + <export name="javax.xml.ws.spi.*"/> + <export name="javax.xml.ws.wsaddressing.*"/> + + </library> + </runtime> + +</fragment> Modified: trunk/core/descriptors/org.classpath.ext.xml.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.xml.xml 2009-02-26 21:41:23 UTC (rev 5065) +++ trunk/core/descriptors/org.classpath.ext.xml.xml 2009-02-26 21:53:20 UTC (rev 5066) @@ -114,18 +114,6 @@ <export name="com.sun.org.apache.xpath.internal.patterns.*"/> <export name="com.sun.org.apache.xpath.internal.res.*"/> - <!-- - <export name="com.sun.xml.internal.bind.*"/> - <export name="com.sun.xml.internal.bind.annotation.*"/> - <export name="com.sun.xml.internal.bind.api.*"/> - <export name="com.sun.xml.internal.bind.api.impl.*"/> - <export name="com.sun.xml.internal.bind.marshaller.*"/> - <export name="com.sun.xml.internal.bind.unmarshaller.*"/> - <export name="com.sun.xml.internal.bind.util.*"/> - <export name="com.sun.xml.internal.bind.v2.*"/> - <export name="com.sun.xml.internal.bind.v2.bytecode.*"/> - <export name="com.sun.xml.internal.bind.v2.model.*"/> - --> <export name="com.sun.xml.internal.stream.*"/> <export name="com.sun.xml.internal.stream.dtd.*"/> <export name="com.sun.xml.internal.stream.dtd.nonvalidating.*"/> @@ -135,12 +123,6 @@ <export name="com.sun.xml.internal.stream.*"/> <export name="javax.xml.*"/> - <export name="javax.xml.bind.*"/> - <export name="javax.xml.bind.annotation.*"/> - <export name="javax.xml.bind.annotation.adapters.*"/> - <export name="javax.xml.bind.attachment.*"/> - <export name="javax.xml.bind.helpers.*"/> - <export name="javax.xml.bind.util.*"/> <export name="javax.xml.crypto.*"/> <export name="javax.xml.crypto.dom.*"/> <export name="javax.xml.crypto.dsig.*"/> @@ -149,16 +131,9 @@ <export name="javax.xml.crypto.dsig.spec.*"/> <export name="javax.xml.datatype.*"/> <export name="javax.xml.namespace.*"/> - <export name="javax.xml.soap.*"/> <export name="javax.xml.transform.sax.*"/> <export name="javax.xml.transform.stax.*"/> <export name="javax.xml.validation.*"/> - <export name="javax.xml.ws.*"/> - <export name="javax.xml.ws.handler.*"/> - <export name="javax.xml.ws.handler.soap.*"/> - <export name="javax.xml.ws.http.*"/> - <export name="javax.xml.ws.soap.*"/> - <export name="javax.xml.ws.spi.*"/> <export name="javax.xml.xpath.*"/> <export name="org.jcp.xml.dsig.internal.*"/> Deleted: trunk/core/lib/mx4j-remote.jar =================================================================== (Binary files differ) Deleted: trunk/core/lib/mx4j.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-02-28 18:59:13
|
Revision: 5073 http://jnode.svn.sourceforge.net/jnode/?rev=5073&view=rev Author: lsantha Date: 2009-02-28 18:59:06 +0000 (Sat, 28 Feb 2009) Log Message: ----------- Reduced code duplication in plugins. Modified Paths: -------------- trunk/core/descriptors/com.sun.tools.javac.xml trunk/core/descriptors/javax.ext.tools.xml trunk/core/descriptors/org.classpath.core.xml trunk/core/descriptors/org.classpath.ext.core.xml trunk/core/descriptors/org.classpath.ext.security.xml trunk/core/descriptors/org.classpath.ext.xml trunk/shell/descriptors/org.jnode.shell.command.debug.xml Modified: trunk/core/descriptors/com.sun.tools.javac.xml =================================================================== --- trunk/core/descriptors/com.sun.tools.javac.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/core/descriptors/com.sun.tools.javac.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -9,6 +9,9 @@ provider-url="http://sun.com" license-name="classpath"> + <requires> + <import plugin="javax.ext.tools"/> + </requires> <runtime> <library name="jnode-core.jar"> <export name="com.sun.mirror.apt.*"/> Modified: trunk/core/descriptors/javax.ext.tools.xml =================================================================== --- trunk/core/descriptors/javax.ext.tools.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/core/descriptors/javax.ext.tools.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -10,9 +10,12 @@ provider-url="http://sun.com" license-name="classpath"> + <requires> + <import plugin="org.classpath.ext.core"/> + </requires> + <runtime> <library name="jnode-core.jar"> - <export name="javax.annotation.*"/> <export name="javax.annotation.processing.*"/> <export name="javax.lang.model.*"/> <export name="javax.lang.model.element.*"/> Modified: trunk/core/descriptors/org.classpath.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.core.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/core/descriptors/org.classpath.core.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -41,8 +41,6 @@ <export name="sun.nio.ByteBuffered"/> <export name="sun.nio.ch.Interruptible"/> <export name="sun.security.acl.GroupImpl"/> - <export name="sun.security.util.Debug"/> - <export name="sun.security.util.SecurityConstants"/> <export name="sun.security.action.*"/> <export name="sun.security.jca.*"/> <export name="sun.security.pkcs.ParsingException"/> @@ -59,30 +57,13 @@ <export name="sun.text.*"/> <export name="sun.text.normalizer.*"/> - <export name="sun.text.resources.BreakIteratorInfo"/> - <export name="sun.text.resources.BreakIteratorRules"/> - <export name="sun.text.resources.CollationData"/> - <export name="sun.text.resources.FormatData"/> + <export name="sun.text.resources.*"/> <export name="sun.util.calendar.*"/> <export name="sun.util.*"/> - <export name="sun.util.resources.LocaleData"/> - <export name="sun.util.resources.LocaleNames"/> - <export name="sun.util.resources.LocaleNamesBundle"/> - <export name="sun.util.resources.OpenListResourceBundle"/> - <export name="sun.util.resources.CalendarData"/> - <export name="sun.util.resources.CurrencyNames"/> - <export name="sun.util.resources.TimeZoneNames"/> + <export name="sun.util.resources.*"/> - <export name="gnu.classpath.Configuration"/> - <export name="gnu.classpath.Pointer"/> - <export name="gnu.classpath.SystemProperties"/> - <export name="gnu.classpath.VMSystemProperties"/> - <export name="gnu.classpath.VMStackWalker"/> - <export name="gnu.classpath.ServiceFactory"/> - <export name="gnu.classpath.ServiceFactory$ServiceIterator"/> - <export name="gnu.classpath.ServiceProviderLoadingAction"/> - + <export name="gnu.classpath.*"/> <export name="gnu.classpath.debug.*"/> <export name="gnu.java.io.*"/> @@ -170,17 +151,10 @@ <export name="javax.crypto.*"/> <export name="javax.crypto.interfaces.*"/> <export name="javax.crypto.spec.*"/> - <export name="javax.security.auth.AuthPermission"/> - <export name="javax.security.auth.Destroyable"/> - <export name="javax.security.auth.DestroyFailedException"/> - <export name="javax.security.auth.Subject"/> - <export name="javax.security.auth.callback.Callback"/> - <export name="javax.security.auth.callback.CallbackHandler"/> - <export name="javax.security.auth.callback.PasswordCallback"/> - <export name="javax.security.auth.callback.UnsupportedCallbackException"/> - <export name="javax.security.auth.login.LoginException"/> - <export name="javax.security.auth.login.Configuration$Parameters"/> - <export name="javax.security.auth.login.Configuration"/> + + <export name="javax.security.auth.*"/> + <export name="javax.security.auth.callback.*"/> + <export name="javax.security.auth.login.*"/> <export name="javax.security.auth.x500.*"/> <export name="org.xml.sax.*"/> Modified: trunk/core/descriptors/org.classpath.ext.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.core.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/core/descriptors/org.classpath.ext.core.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -15,23 +15,11 @@ <export name="com.sun.media.sound.*"/> - <export name="gnu.classpath.*"/> - - <export name="gnu.classpath.jdwp.*"/> - <export name="gnu.classpath.jdwp.event.*"/> - <export name="gnu.classpath.jdwp.event.filters.*"/> - <export name="gnu.classpath.jdwp.exception.*"/> - <export name="gnu.classpath.jdwp.id.*"/> - <export name="gnu.classpath.jdwp.processor.*"/> - <export name="gnu.classpath.jdwp.transport.*"/> - <export name="gnu.classpath.jdwp.util.*"/> - <export name="gnu.java.awt.*"/> <export name="gnu.java.awt.color.*"/> <export name="gnu.java.awt.peer.*"/> <export name="gnu.java.awt.java2d.*"/> <export name="gnu.java.awt.print.*"/> - <export name="gnu.java.lang.reflect.*"/> <export name="gnu.java.net.protocol.*"/> <export name="gnu.java.net.protocol.file.*"/> <export name="gnu.java.net.protocol.ftp.*"/> @@ -86,12 +74,6 @@ <export name="javax.activation.*"/> <export name="javax.activity.*"/> <export name="javax.annotation.*"/> - <export name="javax.annotation.processing.*"/> - <export name="javax.lang.model.*"/> - <export name="javax.lang.model.element.*"/> - <export name="javax.lang.model.type.*"/> - <export name="javax.lang.model.util.*"/> - <export name="javax.management.*"/> <export name="javax.naming.directory.*"/> <export name="javax.naming.event.*"/> <export name="javax.naming.ldap.*"/> @@ -105,8 +87,6 @@ <export name="javax.script.*"/> - <export name="javax.tools.*"/> - <export name="sun.audio.*"/> <export name="sun.net.*"/> @@ -119,11 +99,6 @@ <export name="sun.net.spi.nameservice.dns.META-INF.services.*"/> <export name="sun.security.*"/> - <export name="sun.security.util.*"/> - - <export name="sun.reflect.misc.*"/> - <export name="sun.text.resources.*"/> - <export name="sun.util.resources.*"/> </library> </runtime> Modified: trunk/core/descriptors/org.classpath.ext.security.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.security.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/core/descriptors/org.classpath.ext.security.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -12,7 +12,6 @@ <runtime> <library name="jnode-core.jar"> - <export name="sun.security.util.*"/> <export name="sun.security.tools.*"/> <export name="sun.security.timestamp.*"/> <export name="sun.security.acl.*"/> @@ -20,7 +19,6 @@ <export name="sun.security.internal.interfaces*"/> <export name="sun.security.internal.spec*"/> <export name="sun.security.internal.*"/> - <export name="sun.security.jca.*"/> <export name="sun.security.jgss.*"/> <export name="sun.security.jgss.krb5.*"/> <export name="sun.security.jgss.spi.*"/> Modified: trunk/core/descriptors/org.classpath.ext.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/core/descriptors/org.classpath.ext.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -13,9 +13,6 @@ <runtime> <library name="jnode-core.jar"> <export name="javax.security.*"/> - <export name="javax.security.auth.*"/> - <export name="javax.security.auth.callback.*"/> - <export name="javax.security.auth.login.*"/> <export name="javax.security.auth.spi.*"/> <export name="javax.security.auth.kerberos.*"/> <export name="javax.security.cert.*"/> Modified: trunk/shell/descriptors/org.jnode.shell.command.debug.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.debug.xml 2009-02-28 18:42:21 UTC (rev 5072) +++ trunk/shell/descriptors/org.jnode.shell.command.debug.xml 2009-02-28 18:59:06 UTC (rev 5073) @@ -10,6 +10,7 @@ <requires> <import plugin="org.jnode.debug"/> <import plugin="org.jnode.shell.help"/> + <import plugin="org.classpath.ext.jdwp"/> </requires> <runtime> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-03-08 10:02:19
|
Revision: 5094 http://jnode.svn.sourceforge.net/jnode/?rev=5094&view=rev Author: fduminy Date: 2009-03-08 10:02:17 +0000 (Sun, 08 Mar 2009) Log Message: ----------- fixed build process to support multiple versions of a library (aka 2 plugins with the same id but with a different version) Modified Paths: -------------- trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java trunk/builder/src/builder/org/jnode/build/InitJarBuilder.java trunk/builder/src/builder/org/jnode/build/PluginList.java trunk/builder/src/builder/org/jnode/build/packager/PluginListInsertor.java trunk/core/src/core/org/jnode/plugin/PluginDescriptor.java trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java Modified: trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -407,7 +407,7 @@ try { log("plugin-list: " + getPluginListFile(), Project.MSG_DEBUG); piList = getPluginList(); - memMgrPluginURL = piList.createPluginURL(memMgrPluginId); + memMgrPluginURL = piList.createPluginURL(memMgrPluginId, version); lmPI = Math.max(piList.lastModified(), memMgrPluginURL.openConnection().getLastModified()); } catch (PluginException ex) { throw new BuildException(ex); Modified: trunk/builder/src/builder/org/jnode/build/InitJarBuilder.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/InitJarBuilder.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/builder/src/builder/org/jnode/build/InitJarBuilder.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -24,9 +24,11 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.tools.ant.Project; @@ -188,20 +190,49 @@ */ protected void testPluginPrerequisites(List<PluginJar> pluginJars) throws BuildException { - final HashSet<String> ids = new HashSet<String>(); - + final Map<String, List<String>> idToVersions = new HashMap<String, List<String>>(); + + // get all couples (id, version) in idToVersions for (PluginJar piJar : pluginJars) { final PluginDescriptor descr = piJar.getDescriptor(); - ids.add(descr.getId()); + + List<String> versions = idToVersions.get(descr.getId()); + if (versions == null) { + versions = new ArrayList<String>(); + idToVersions.put(descr.getId(), versions); + } + + versions.add(descr.getVersion()); } + + // now, check that each dependency is satisfied for (PluginJar piJar : pluginJars) { final PluginDescriptor descr = piJar.getDescriptor(); final PluginPrerequisite[] prereqs = descr.getPrerequisites(); + for (int j = 0; j < prereqs.length; j++) { - if (!ids.contains(prereqs[j].getPluginId())) { + PluginPrerequisite required = prereqs[j]; + List<String> versions = idToVersions.get(required.getPluginId()); + + boolean versionSpecified = (required.getPluginVersion() == null); + + boolean satisfied = false; + if (versions != null) { + satisfied = !versionSpecified || + versions.contains(required.getPluginVersion()); + } + + if (!satisfied) { + String reqVersionStr = versionSpecified ? "" : " version " + + required.getPluginVersion(); + + String versionStr = (descr.getVersion() == null) ? "" : " version " + + descr.getVersion(); + throw new BuildException("Cannot find plugin " - + prereqs[j].getPluginId() - + ", which is required by " + descr.getId()); + + required.getPluginId() + reqVersionStr + + ", which is required by " + descr.getId() + + versionStr); } } } Modified: trunk/builder/src/builder/org/jnode/build/PluginList.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/PluginList.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/builder/src/builder/org/jnode/build/PluginList.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -90,8 +90,12 @@ throw new PluginException("id attribute expected on " + e.getName()); } + + // version attribute is optional + // if not specified, then the latest version found will be used. + final String version = e.getStringAttribute("version"); - addPlugin(descrList, pluginList, id); + addPlugin(descrList, pluginList, id, version); } else if (e.getName().equals("manifest")) { manifest = parseManifest(e); } else if (e.getName().equals("include")) { @@ -103,39 +107,76 @@ } } - public void addPlugin(String id) throws MalformedURLException, PluginException { - addPlugin(descrList, pluginList, id); + /** + * + * @param id + * @param version optional + * @throws MalformedURLException + * @throws PluginException + */ + public void addPlugin(String id, String version) throws MalformedURLException, PluginException { + addPlugin(descrList, pluginList, id, version); } - private void addPlugin(List<URL> descrList, List<URL> pluginList, String id) + /** + * + * @param descrList + * @param pluginList + * @param id + * @param version optional parameter + * @throws MalformedURLException + * @throws PluginException + */ + private void addPlugin(List<URL> descrList, List<URL> pluginList, String id, String version) throws MalformedURLException, PluginException { - final File f = findPlugin(defaultDir, id); + final File f = findPlugin(defaultDir, id, version); final URL pluginUrl = f.toURL(); final URL descrUrl = new URL("jar:" + pluginUrl + "!/plugin.xml"); - + if (pluginList.contains(pluginUrl)) { - throw new PluginException("can't use the same id(" + id + ") for multiple plugins"); + String versionStr = (version == null) ? "unspecified" : version; + throw new PluginException("can't use the same id(" + id + + ") and version(" + versionStr + ") for multiple plugins"); } descrList.add(descrUrl); pluginList.add(pluginUrl); } - private File findPlugin(File dir, final String id) { + private File findPlugin(File dir, final String id, String version) { // System.out.println("Find " + id + " in " + dir); + final String begin = id + "_"; + final String end = ".jar"; + String[] names = dir.list(new FilenameFilter() { public boolean accept(File dir, String name) { - return name.startsWith(id + "_") && name.endsWith(".jar"); + return name.startsWith(begin) && name.endsWith(end); } }); if (names.length == 0) { throw new IllegalArgumentException("Cannot find plugin " + id + " in " + dir + " for list " + this.name); - } else { - Arrays.sort(names); - return new File(dir, names[names.length - 1]); } + + String filename = null; + if (version != null) { + // version specified, try to find it + for (String name : names) { + String v = name.substring(begin.length(), name.length() - end.length()); + if (version.equals(v)) { + filename = name; // found exact version + break; + } + } + } + + if (filename == null) { + // by default, take the latest version + filename = names[names.length - 1]; + } + + return new File(dir, filename); } private Manifest parseManifest(XMLElement me) throws PluginException { @@ -239,11 +280,11 @@ } /** - * Create an URL to a plugin with a given id. + * Create an URL to a plugin with a given id and version. */ - public final URL createPluginURL(String id) { + public final URL createPluginURL(String id, String version) { try { - return findPlugin(defaultDir, id).toURL(); + return findPlugin(defaultDir, id, version).toURL(); } catch (MalformedURLException e) { throw new RuntimeException(e); } Modified: trunk/builder/src/builder/org/jnode/build/packager/PluginListInsertor.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/packager/PluginListInsertor.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/builder/src/builder/org/jnode/build/packager/PluginListInsertor.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -49,7 +49,7 @@ if (isEnabled()) { for (String pluginId : readPluginIds(list.getName())) { log("Adding user plugin " + pluginId + " to " + list.getName(), Project.MSG_INFO); - list.addPlugin(pluginId); + list.addPlugin(pluginId, null); } } else { log("PluginListInsertor is disabled", Project.MSG_INFO); Modified: trunk/core/src/core/org/jnode/plugin/PluginDescriptor.java =================================================================== --- trunk/core/src/core/org/jnode/plugin/PluginDescriptor.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/core/src/core/org/jnode/plugin/PluginDescriptor.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -80,8 +80,14 @@ * @return the version */ public abstract String getVersion(); - + /** + * Get the plugin reference, something that uniquely identify a plugin (id + version) + * @return + */ + public PluginReference getPluginReference(); + + /** * Gets the required imports. * * @return the required imports Modified: trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java =================================================================== --- trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -38,6 +38,7 @@ import org.jnode.plugin.PluginDescriptorListener; import org.jnode.plugin.PluginException; import org.jnode.plugin.PluginPrerequisite; +import org.jnode.plugin.PluginReference; import org.jnode.plugin.Runtime; import org.jnode.system.BootLog; import org.jnode.util.BootableArrayList; @@ -106,6 +107,8 @@ private final String version; private final int priority; + + private PluginReference reference; /** * Create a new instance @@ -529,6 +532,17 @@ public String getVersion() { return version; } + + /** + * {@inheritDoc} + */ + public PluginReference getPluginReference() { + if (reference == null) { + // lazy creation + reference = new PluginReference(id, version); + } + return reference; + } /** * Does this plugin have a custom plugin class specified? Modified: trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java =================================================================== --- trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -435,7 +435,7 @@ } // Now remove it - unloadedIds.add(new PluginReference(descr.getId(), descr.getVersion())); + unloadedIds.add(descr.getPluginReference()); descr.unresolve(this); } } Modified: trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java =================================================================== --- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java 2009-03-08 09:22:32 UTC (rev 5093) +++ trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java 2009-03-08 10:02:17 UTC (rev 5094) @@ -30,6 +30,7 @@ import org.jnode.plugin.PluginDescriptorListener; import org.jnode.plugin.PluginException; import org.jnode.plugin.PluginPrerequisite; +import org.jnode.plugin.PluginReference; import org.jnode.plugin.Runtime; /** @@ -158,4 +159,8 @@ // TODO Auto-generated method stub } + + public PluginReference getPluginReference() { + return null; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-03-13 20:11:36
|
Revision: 5099 http://jnode.svn.sourceforge.net/jnode/?rev=5099&view=rev Author: lsantha Date: 2009-03-13 20:11:26 +0000 (Fri, 13 Mar 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/src/classpath/vm/java/lang/Thread.java Added Paths: ----------- trunk/core/src/openjdk/java/java/lang/InheritableThreadLocal.java trunk/core/src/openjdk/java/java/lang/ThreadLocal.java Removed Paths: ------------- trunk/core/src/classpath/java/java/lang/InheritableThreadLocal.java trunk/core/src/classpath/java/java/lang/ThreadLocal.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-03-13 20:07:21 UTC (rev 5098) +++ trunk/all/conf/openjdk-annotations.properties 2009-03-13 20:11:26 UTC (rev 5099) @@ -5,16 +5,17 @@ # package/className.class=<annotations list separated by a ','> # supported annotations : SharedStatics, MagicPermission -java/lang/Throwable.class=MagicPermission -java/util/Currency.class=SharedStatics -sun/misc/SharedSecrets.class=SharedStatics -sun/misc/Unsafe.class=SharedStatics java/awt/EventQueue.class=SharedStatics +java/awt/image/DataBuffer.class=SharedStatics java/awt/KeyboardFocusManager.class=SharedStatics java/awt/Toolkit.class=SharedStatics +java/lang/ThreadLocal.class=SharedStatics +java/lang/Throwable.class=MagicPermission +java/util/Currency.class=SharedStatics +java/util/concurrent/locks/LockSupport.class=SharedStatics sun/awt/AppContext.class=SharedStatics sun/awt/AWTAutoShutdown.class=SharedStatics sun/awt/image/SunWritableRaster.class=SharedStatics sun/java2d/Disposer.class=SharedStatics -java/awt/image/DataBuffer.class=SharedStatics -java/util/concurrent/locks/LockSupport.class=SharedStatics +sun/misc/SharedSecrets.class=SharedStatics +sun/misc/Unsafe.class=SharedStatics Deleted: trunk/core/src/classpath/java/java/lang/InheritableThreadLocal.java =================================================================== --- trunk/core/src/classpath/java/java/lang/InheritableThreadLocal.java 2009-03-13 20:07:21 UTC (rev 5098) +++ trunk/core/src/classpath/java/java/lang/InheritableThreadLocal.java 2009-03-13 20:11:26 UTC (rev 5099) @@ -1,119 +0,0 @@ -/* InheritableThreadLocal -- a ThreadLocal which inherits values across threads - Copyright (C) 2000, 2001, 2002, 2003, 2005 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 java.lang; - -import java.util.Iterator; -import java.util.WeakHashMap; - -/** - * A ThreadLocal whose value is inherited by child Threads. The value of the - * InheritableThreadLocal associated with the (parent) Thread is copied to - * the new (child) Thread at the moment of creation. - * - * <p>It is possible to make the value associated with the child Thread a - * function of the value that is associated with the parent Thread by - * overriding the <code>childValue()</code> method. The utility of this class - * is in transferring items like User ID or Transaction ID across threads - * automatically. - * - * @author Mark Wielaard (ma...@kl...) - * @author Eric Blake (eb...@em...) - * @author Tom Tromey (tr...@re...) - * @author Andrew John Hughes (gnu...@me...) - * @see ThreadLocal - * @since 1.2 - * @status updated to 1.4 - */ -public class InheritableThreadLocal<T> extends ThreadLocal<T> -{ - - /** - * Creates a new InheritableThreadLocal that has no values associated - * with it yet. - */ - public InheritableThreadLocal() - { - } - - /** - * Determines the value associated with a newly created child Thread as a - * function of the value associated with the currently executing (parent) - * Thread. The default implementation just returns the parentValue. - * - * @param parentValue the value of this object in the parent thread at - * the moment of creation of the child - * @return the initial value for the child thread - */ - protected Object childValue(Object parentValue) - { - return parentValue; - } - - /** - * Generates the childValues of all <code>InheritableThreadLocal</code>s - * that are in the heritage of the current Thread for the newly created - * childThread. Should be called from the contructor Thread. - * - * @param childThread the newly created thread, to inherit from this thread - * @see Thread#Thread(ThreadGroup, Runnable, String) - */ - static void newChildThread(Thread childThread) - { - // The currentThread is the parent of the new thread. - Thread parentThread = Thread.currentThread(); - if (parentThread.locals != null) - { - Iterator keys = parentThread.locals.keySet().iterator(); - while (keys.hasNext()) - { - ThreadLocal.Key key = (ThreadLocal.Key)keys.next(); - if (key.get() instanceof InheritableThreadLocal) - { - InheritableThreadLocal local = (InheritableThreadLocal)key.get(); - Object parentValue = parentThread.locals.get(key); - Object childValue = local.childValue(parentValue == NULL - ? null : parentValue); - if (childThread.locals == null) - childThread.locals = new WeakHashMap(); - childThread.locals.put(key, (childValue == null - ? NULL : childValue)); - } - } - } - } -} Deleted: trunk/core/src/classpath/java/java/lang/ThreadLocal.java =================================================================== --- trunk/core/src/classpath/java/java/lang/ThreadLocal.java 2009-03-13 20:07:21 UTC (rev 5098) +++ trunk/core/src/classpath/java/java/lang/ThreadLocal.java 2009-03-13 20:11:26 UTC (rev 5099) @@ -1,181 +0,0 @@ -/* ThreadLocal -- a variable with a unique value per thread - Copyright (C) 2000, 2002, 2003 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 java.lang; - -import java.util.Map; - - -/** - * ThreadLocal objects have a different state associated with every - * Thread that accesses them. Every access to the ThreadLocal object - * (through the <code>get()</code> and <code>set()</code> methods) - * only affects the state of the object as seen by the currently - * executing Thread. - * - * <p>The first time a ThreadLocal object is accessed on a particular - * Thread, the state for that Thread's copy of the local variable is set by - * executing the method <code>initialValue()</code>. - * </p> - * - * <p>An example how you can use this: - * </p> - * - * <pre> - * class Connection - * { - * private static ThreadLocal owner = new ThreadLocal() - * { - * public Object initialValue() - * { - * return("nobody"); - * } - * }; - * ... - * } - * </pre> - * - * <p>Now all instances of connection can see who the owner of the currently - * executing Thread is by calling <code>owner.get()</code>. By default any - * Thread would be associated with 'nobody'. But the Connection object could - * offer a method that changes the owner associated with the Thread on - * which the method was called by calling <code>owner.put("somebody")</code>. - * (Such an owner changing method should then be guarded by security checks.) - * </p> - * - * <p>When a Thread is garbage collected all references to values of - * the ThreadLocal objects associated with that Thread are removed. - * </p> - * - * @author Mark Wielaard (ma...@kl...) - * @author Eric Blake (eb...@em...) - * @since 1.2 - * @status updated to 1.5 - */ -public class ThreadLocal<T> -{ - /** - * Placeholder to distinguish between uninitialized and null set by the - * user. Do not expose this to the public. Package visible for use by - * InheritableThreadLocal - */ - static final Object NULL = new Object(); - - /** - * Serves as a key for the Thread.locals WeakHashMap. - * We can't use "this", because a subclass may override equals/hashCode - * and we need to use object identity for the map. - */ - final Key key = new Key(); - - class Key - { - ThreadLocal get() - { - return ThreadLocal.this; - } - } - - /** - * Creates a ThreadLocal object without associating any value to it yet. - */ - public ThreadLocal() - { - } - - /** - * Called once per thread on the first invocation of get(), if set() was - * not already called. The default implementation returns <code>null</code>. - * Often, this method is overridden to create the appropriate initial object - * for the current thread's view of the ThreadLocal. - * - * @return the initial value of the variable in this thread - */ - protected T initialValue() - { - return null; - } - - /** - * Gets the value associated with the ThreadLocal object for the currently - * executing Thread. If this is the first time the current thread has called - * get(), and it has not already called set(), the value is obtained by - * <code>initialValue()</code>. - * - * @return the value of the variable in this thread - */ - public T get() - { - Map map = Thread.getThreadLocals(); - // Note that we don't have to synchronize, as only this thread will - // ever modify the map. - Object value = map.get(key); - if (value == null) - { - value = initialValue(); - map.put(key, value == null ? NULL : value); - } - return value == NULL ? null : (T) value; - } - - /** - * Sets the value associated with the ThreadLocal object for the currently - * executing Thread. This overrides any existing value associated with the - * current Thread and prevents <code>initialValue()</code> from being - * called if this is the first access to this ThreadLocal in this Thread. - * - * @param value the value to set this thread's view of the variable to - */ - public void set(T value) - { - Map map = Thread.getThreadLocals(); - // Note that we don't have to synchronize, as only this thread will - // ever modify the map. - map.put(key, value == null ? NULL : value); - } - - /** - * Removes the value associated with the ThreadLocal object for the - * currently executing Thread. - * @since 1.5 - */ - public void remove() - { - Map map = Thread.getThreadLocals(); - map.remove(this); -} -} Modified: trunk/core/src/classpath/vm/java/lang/Thread.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/Thread.java 2009-03-13 20:07:21 UTC (rev 5098) +++ trunk/core/src/classpath/vm/java/lang/Thread.java 2009-03-13 20:11:26 UTC (rev 5099) @@ -39,7 +39,6 @@ package java.lang; import java.util.Map; -import java.util.WeakHashMap; import java.util.HashMap; @@ -101,7 +100,6 @@ * @see #start() * @see ThreadLocal * @since 1.0 - * @status updated to 1.4 */ @SharedStatics public class Thread implements Runnable @@ -141,15 +139,20 @@ private final Thread parent; /** The default exception handler. */ - private static UncaughtExceptionHandler defaultHandler; + private static UncaughtExceptionHandler defaultHandler; - /** Thread local storage. Package accessible for use by - * InheritableThreadLocal. + /* ThreadLocal values pertaining to this thread. This map is maintained + * by the ThreadLocal class. */ + ThreadLocal.ThreadLocalMap threadLocals = null; + + /* + * InheritableThreadLocal values pertaining to this thread. This map is + * maintained by the InheritableThreadLocal class. */ - WeakHashMap locals; + ThreadLocal.ThreadLocalMap inheritableThreadLocals = null; /** The uncaught exception handler. */ - UncaughtExceptionHandler exceptionHandler; + UncaughtExceptionHandler exceptionHandler; /** * Name and number of threads created. Used only for generating unique names. @@ -158,8 +161,7 @@ */ private static final HashMap<String, Integer> nameMap = new HashMap<String, Integer>(); - private static final JNodePermission GETVMTHREAD_PERM = new JNodePermission( - "getVmThread"); + private static final JNodePermission GETVMTHREAD_PERM = new JNodePermission("getVmThread"); /** * Allocates a new <code>Thread</code> object. This constructor has @@ -345,8 +347,9 @@ this.vmThread = VmProcessor.current().createThread(this); this.vmThread.setPriority(current.getPriority()); this.vmThread.updateName(); - - InheritableThreadLocal.newChildThread(this); // FDy : CLASSPATH patch ? + + if (parent.inheritableThreadLocals != null) + this.inheritableThreadLocals = ThreadLocal.createInheritedMap(parent.inheritableThreadLocals); } /** @@ -396,7 +399,8 @@ this.vmThread.setPriority(current.getPriority()); this.vmThread.updateName(); - InheritableThreadLocal.newChildThread(this); // FDy : CLASSPATH patch ? + if (parent.inheritableThreadLocals != null) + this.inheritableThreadLocals = ThreadLocal.createInheritedMap(parent.inheritableThreadLocals); } /** @@ -431,8 +435,11 @@ this.vmThread = VmProcessor.current().createThread(isolatedStatics, this); this.vmThread.setPriority(this.getPriority()); this.vmThread.updateName(); - - InheritableThreadLocal.newChildThread(this); // FDy : CLASSPATH patch ? + + //todo review it: should thread locals be inherited accorss isolates? Probably not... + ThreadLocal.ThreadLocalMap parentLocals = currentThread().inheritableThreadLocals; + if (parentLocals != null) + this.inheritableThreadLocals = ThreadLocal.createInheritedMap(parentLocals); } /** @@ -1067,19 +1074,6 @@ } /** - * Returns the map used by ThreadLocal to store the thread local values. - */ - static Map getThreadLocals() { - Thread thread = currentThread(); - Map locals = thread.locals; - if (locals == null) - { - locals = thread.locals = new WeakHashMap(); - } - return locals; - } - - /** * Assigns the given <code>UncaughtExceptionHandler</code> to this * thread. This will then be called if the thread terminates due * to an uncaught exception, pre-empting that of the @@ -1213,6 +1207,8 @@ public final void onExit() { if (vmThread.isStopping()) { group.remove(this); + threadLocals = null; + inheritableThreadLocals = null; } } @@ -1466,5 +1462,4 @@ // blocker = b; // } } - } Added: trunk/core/src/openjdk/java/java/lang/InheritableThreadLocal.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/InheritableThreadLocal.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/InheritableThreadLocal.java 2009-03-13 20:11:26 UTC (rev 5099) @@ -0,0 +1,84 @@ +/* + * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.lang; +import java.lang.ref.*; + +/** + * This class extends <tt>ThreadLocal</tt> to provide inheritance of values + * from parent thread to child thread: when a child thread is created, the + * child receives initial values for all inheritable thread-local variables + * for which the parent has values. Normally the child's values will be + * identical to the parent's; however, the child's value can be made an + * arbitrary function of the parent's by overriding the <tt>childValue</tt> + * method in this class. + * + * <p>Inheritable thread-local variables are used in preference to + * ordinary thread-local variables when the per-thread-attribute being + * maintained in the variable (e.g., User ID, Transaction ID) must be + * automatically transmitted to any child threads that are created. + * + * @author Josh Bloch and Doug Lea + * @see ThreadLocal + * @since 1.2 + */ + +public class InheritableThreadLocal<T> extends ThreadLocal<T> { + /** + * Computes the child's initial value for this inheritable thread-local + * variable as a function of the parent's value at the time the child + * thread is created. This method is called from within the parent + * thread before the child is started. + * <p> + * This method merely returns its input argument, and should be overridden + * if a different behavior is desired. + * + * @param parentValue the parent thread's value + * @return the child thread's initial value + */ + protected T childValue(T parentValue) { + return parentValue; + } + + /** + * Get the map associated with a ThreadLocal. + * + * @param t the current thread + */ + ThreadLocalMap getMap(Thread t) { + return t.inheritableThreadLocals; + } + + /** + * Create the map associated with a ThreadLocal. + * + * @param t the current thread + * @param firstValue value for the initial entry of the table. + * @param map the map to store. + */ + void createMap(Thread t, T firstValue) { + t.inheritableThreadLocals = new ThreadLocalMap(this, firstValue); + } +} Added: trunk/core/src/openjdk/java/java/lang/ThreadLocal.java =================================================================== --- trunk/core/src/openjdk/java/java/lang/ThreadLocal.java (rev 0) +++ trunk/core/src/openjdk/java/java/lang/ThreadLocal.java 2009-03-13 20:11:26 UTC (rev 5099) @@ -0,0 +1,697 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.lang; +import java.lang.ref.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * This class provides thread-local variables. These variables differ from + * their normal counterparts in that each thread that accesses one (via its + * <tt>get</tt> or <tt>set</tt> method) has its own, independently initialized + * copy of the variable. <tt>ThreadLocal</tt> instances are typically private + * static fields in classes that wish to associate state with a thread (e.g., + * a user ID or Transaction ID). + * + * <p>For example, the class below generates unique identifiers local to each + * thread. + * A thread's id is assigned the first time it invokes <tt>ThreadId.get()</tt> + * and remains unchanged on subsequent calls. + * <pre> + * import java.util.concurrent.atomic.AtomicInteger; + * + * public class ThreadId { + * // Atomic integer containing the next thread ID to be assigned + * private static final AtomicInteger nextId = new AtomicInteger(0); + * + * // Thread local variable containing each thread's ID + * private static final ThreadLocal<Integer> threadId = + * new ThreadLocal<Integer>() { + * @Override protected Integer initialValue() { + * return nextId.getAndIncrement(); + * } + * }; + * + * // Returns the current thread's unique ID, assigning it if necessary + * public static int get() { + * return threadId.get(); + * } + * } + * </pre> + * <p>Each thread holds an implicit reference to its copy of a thread-local + * variable as long as the thread is alive and the <tt>ThreadLocal</tt> + * instance is accessible; after a thread goes away, all of its copies of + * thread-local instances are subject to garbage collection (unless other + * references to these copies exist). + * + * @author Josh Bloch and Doug Lea + * @since 1.2 + */ +public class ThreadLocal<T> { + /** + * ThreadLocals rely on per-thread linear-probe hash maps attached + * to each thread (Thread.threadLocals and + * inheritableThreadLocals). The ThreadLocal objects act as keys, + * searched via threadLocalHashCode. This is a custom hash code + * (useful only within ThreadLocalMaps) that eliminates collisions + * in the common case where consecutively constructed ThreadLocals + * are used by the same threads, while remaining well-behaved in + * less common cases. + */ + private final int threadLocalHashCode = nextHashCode(); + + /** + * The next hash code to be given out. Updated atomically. Starts at + * zero. + */ +//jnode todo: unsing AtomicInteger here breaks the boot process, why? +// private static AtomicInteger nextHashCode = +// new AtomicInteger(); + private static Integer nextHashCode = 0; + + /** + * The difference between successively generated hash codes - turns + * implicit sequential thread-local IDs into near-optimally spread + * multiplicative hash values for power-of-two-sized tables. + */ + private static final int HASH_INCREMENT = 0x61c88647; + + /** + * Returns the next hash code. + */ + private static int nextHashCode() { +// return nextHashCode.getAndAdd(HASH_INCREMENT); + return nextHashCode += HASH_INCREMENT; + } + + /** + * Returns the current thread's "initial value" for this + * thread-local variable. This method will be invoked the first + * time a thread accesses the variable with the {@link #get} + * method, unless the thread previously invoked the {@link #set} + * method, in which case the <tt>initialValue</tt> method will not + * be invoked for the thread. Normally, this method is invoked at + * most once per thread, but it may be invoked again in case of + * subsequent invocations of {@link #remove} followed by {@link #get}. + * + * <p>This implementation simply returns <tt>null</tt>; if the + * programmer desires thread-local variables to have an initial + * value other than <tt>null</tt>, <tt>ThreadLocal</tt> must be + * subclassed, and this method overridden. Typically, an + * anonymous inner class will be used. + * + * @return the initial value for this thread-local + */ + protected T initialValue() { + return null; + } + + /** + * Creates a thread local variable. + */ + public ThreadLocal() { + } + + /** + * Returns the value in the current thread's copy of this + * thread-local variable. If the variable has no value for the + * current thread, it is first initialized to the value returned + * by an invocation of the {@link #initialValue} method. + * + * @return the current thread's value of this thread-local + */ + public T get() { + Thread t = Thread.currentThread(); + ThreadLocalMap map = getMap(t); + if (map != null) { + ThreadLocalMap.Entry e = map.getEntry(this); + if (e != null) + return (T)e.value; + } + return setInitialValue(); + } + + /** + * Variant of set() to establish initialValue. Used instead + * of set() in case user has overridden the set() method. + * + * @return the initial value + */ + private T setInitialValue() { + T value = initialValue(); + Thread t = Thread.currentThread(); + ThreadLocalMap map = getMap(t); + if (map != null) + map.set(this, value); + else + createMap(t, value); + return value; + } + + /** + * Sets the current thread's copy of this thread-local variable + * to the specified value. Most subclasses will have no need to + * override this method, relying solely on the {@link #initialValue} + * method to set the values of thread-locals. + * + * @param value the value to be stored in the current thread's copy of + * this thread-local. + */ + public void set(T value) { + Thread t = Thread.currentThread(); + ThreadLocalMap map = getMap(t); + if (map != null) + map.set(this, value); + else + createMap(t, value); + } + + /** + * Removes the current thread's value for this thread-local + * variable. If this thread-local variable is subsequently + * {@linkplain #get read} by the current thread, its value will be + * reinitialized by invoking its {@link #initialValue} method, + * unless its value is {@linkplain #set set} by the current thread + * in the interim. This may result in multiple invocations of the + * <tt>initialValue</tt> method in the current thread. + * + * @since 1.5 + */ + public void remove() { + ThreadLocalMap m = getMap(Thread.currentThread()); + if (m != null) + m.remove(this); + } + + /** + * Get the map associated with a ThreadLocal. Overridden in + * InheritableThreadLocal. + * + * @param t the current thread + * @return the map + */ + ThreadLocalMap getMap(Thread t) { + return t.threadLocals; + } + + /** + * Create the map associated with a ThreadLocal. Overridden in + * InheritableThreadLocal. + * + * @param t the current thread + * @param firstValue value for the initial entry of the map + * @param map the map to store. + */ + void createMap(Thread t, T firstValue) { + t.threadLocals = new ThreadLocalMap(this, firstValue); + } + + /** + * Factory method to create map of inherited thread locals. + * Designed to be called only from Thread constructor. + * + * @param parentMap the map associated with parent thread + * @return a map containing the parent's inheritable bindings + */ + static ThreadLocalMap createInheritedMap(ThreadLocalMap parentMap) { + return new ThreadLocalMap(parentMap); + } + + /** + * Method childValue is visibly defined in subclass + * InheritableThreadLocal, but is internally defined here for the + * sake of providing createInheritedMap factory method without + * needing to subclass the map class in InheritableThreadLocal. + * This technique is preferable to the alternative of embedding + * instanceof tests in methods. + */ + T childValue(T parentValue) { + throw new UnsupportedOperationException(); + } + + /** + * ThreadLocalMap is a customized hash map suitable only for + * maintaining thread local values. No operations are exported + * outside of the ThreadLocal class. The class is package private to + * allow declaration of fields in class Thread. To help deal with + * very large and long-lived usages, the hash table entries use + * WeakReferences for keys. However, since reference queues are not + * used, stale entries are guaranteed to be removed only when + * the table starts running out of space. + */ + static class ThreadLocalMap { + + /** + * The entries in this hash map extend WeakReference, using + * its main ref field as the key (which is always a + * ThreadLocal object). Note that null keys (i.e. entry.get() + * == null) mean that the key is no longer referenced, so the + * entry can be expunged from table. Such entries are referred to + * as "stale entries" in the code that follows. + */ + static class Entry { //jnode + /** The value associated with this ThreadLocal. */ + Object value; + ThreadLocal k; + + public ThreadLocal get() { + return k; + } + + public void clear() { + k = null; + } + + Entry(ThreadLocal k, Object v) { + this.k = k; + value = v; + } + } + + /** + * The initial capacity -- MUST be a power of two. + */ + private static final int INITIAL_CAPACITY = 16; + + /** + * The table, resized as necessary. + * table.length MUST always be a power of two. + */ + private Entry[] table; + + /** + * The number of entries in the table. + */ + private int size = 0; + + /** + * The next size value at which to resize. + */ + private int threshold; // Default to 0 + + /** + * Set the resize threshold to maintain at worst a 2/3 load factor. + */ + private void setThreshold(int len) { + threshold = len * 2 / 3; + } + + /** + * Increment i modulo len. + */ + private static int nextIndex(int i, int len) { + return ((i + 1 < len) ? i + 1 : 0); + } + + /** + * Decrement i modulo len. + */ + private static int prevIndex(int i, int len) { + return ((i - 1 >= 0) ? i - 1 : len - 1); + } + + /** + * Construct a new map initially containing (firstKey, firstValue). + * ThreadLocalMaps are constructed lazily, so we only create + * one when we have at least one entry to put in it. + */ + ThreadLocalMap(ThreadLocal firstKey, Object firstValue) { + table = new Entry[INITIAL_CAPACITY]; + int i = firstKey.threadLocalHashCode & (INITIAL_CAPACITY - 1); + table[i] = new Entry(firstKey, firstValue); + size = 1; + setThreshold(INITIAL_CAPACITY); + } + + /** + * Construct a new map including all Inheritable ThreadLocals + * from given parent map. Called only by createInheritedMap. + * + * @param parentMap the map associated with parent thread. + */ + private ThreadLocalMap(ThreadLocalMap parentMap) { + Entry[] parentTable = parentMap.table; + int len = parentTable.length; + setThreshold(len); + table = new Entry[len]; + + for (int j = 0; j < len; j++) { + Entry e = parentTable[j]; + if (e != null) { + ThreadLocal key = e.get(); + if (key != null) { + Object value = key.childValue(e.value); + Entry c = new Entry(key, value); + int h = key.threadLocalHashCode & (len - 1); + while (table[h] != null) + h = nextIndex(h, len); + table[h] = c; + size++; + } + } + } + } + + /** + * Get the entry associated with key. This method + * itself handles only the fast path: a direct hit of existing + * key. It otherwise relays to getEntryAfterMiss. This is + * designed to maximize performance for direct hits, in part + * by making this method readily inlinable. + * + * @param key the thread local object + * @return the entry associated with key, or null if no such + */ + private Entry getEntry(ThreadLocal key) { + int i = key.threadLocalHashCode & (table.length - 1); + Entry e = table[i]; + if (e != null && e.get() == key) + return e; + else + return getEntryAfterMiss(key, i, e); + } + + /** + * Version of getEntry method for use when key is not found in + * its direct hash slot. + * + * @param key the thread local object + * @param i the table index for key's hash code + * @param e the entry at table[i] + * @return the entry associated with key, or null if no such + */ + private Entry getEntryAfterMiss(ThreadLocal key, int i, Entry e) { + Entry[] tab = table; + int len = tab.length; + + while (e != null) { + ThreadLocal k = e.get(); + if (k == key) + return e; + if (k == null) + expungeStaleEntry(i); + else + i = nextIndex(i, len); + e = tab[i]; + } + return null; + } + + /** + * Set the value associated with key. + * + * @param key the thread local object + * @param value the value to be set + */ + private void set(ThreadLocal key, Object value) { + + // We don't use a fast path as with get() because it is at + // least as common to use set() to create new entries as + // it is to replace existing ones, in which case, a fast + // path would fail more often than not. + + Entry[] tab = table; + int len = tab.length; + int i = key.threadLocalHashCode & (len-1); + + for (Entry e = tab[i]; + e != null; + e = tab[i = nextIndex(i, len)]) { + ThreadLocal k = e.get(); + + if (k == key) { + e.value = value; + return; + } + + if (k == null) { + replaceStaleEntry(key, value, i); + return; + } + } + + tab[i] = new Entry(key, value); + int sz = ++size; + if (!cleanSomeSlots(i, sz) && sz >= threshold) + rehash(); + } + + /** + * Remove the entry for key. + */ + private void remove(ThreadLocal key) { + Entry[] tab = table; + int len = tab.length; + int i = key.threadLocalHashCode & (len-1); + for (Entry e = tab[i]; + e != null; + e = tab[i = nextIndex(i, len)]) { + if (e.get() == key) { + e.clear(); + expungeStaleEntry(i); + return; + } + } + } + + /** + * Replace a stale entry encountered during a set operation + * with an entry for the specified key. The value passed in + * the value parameter is stored in the entry, whether or not + * an entry already exists for the specified key. + * + * As a side effect, this method expunges all stale entries in the + * "run" containing the stale entry. (A run is a sequence of entries + * between two null slots.) + * + * @param key the key + * @param value the value to be associated with key + * @param staleSlot index of the first stale entry encountered while + * searching for key. + */ + private void replaceStaleEntry(ThreadLocal key, Object value, + int staleSlot) { + Entry[] tab = table; + int len = tab.length; + Entry e; + + // Back up to check for prior stale entry in current run. + // We clean out whole runs at a time to avoid continual + // incremental rehashing due to garbage collector freeing + // up refs in bunches (i.e., whenever the collector runs). + int slotToExpunge = staleSlot; + for (int i = prevIndex(staleSlot, len); + (e = tab[i]) != null; + i = prevIndex(i, len)) + if (e.get() == null) + slotToExpunge = i; + + // Find either the key or trailing null slot of run, whichever + // occurs first + for (int i = nextIndex(staleSlot, len); + (e = tab[i]) != null; + i = nextIndex(i, len)) { + ThreadLocal k = e.get(); + + // If we find key, then we need to swap it + // with the stale entry to maintain hash table order. + // The newly stale slot, or any other stale slot + // encountered above it, can then be sent to expungeStaleEntry + // to remove or rehash all of the other entries in run. + if (k == key) { + e.value = value; + + tab[i] = tab[staleSlot]; + tab[staleSlot] = e; + + // Start expunge at preceding stale entry if it exists + if (slotToExpunge == staleSlot) + slotToExpunge = i; + cleanSomeSlots(expungeStaleEntry(slotToExpunge), len); + return; + } + + // If we didn't find stale entry on backward scan, the + // first stale entry seen while scanning for key is the + // first still present in the run. + if (k == null && slotToExpunge == staleSlot) + slotToExpunge = i; + } + + // If key not found, put new entry in stale slot + tab[staleSlot].value = null; + tab[staleSlot] = new Entry(key, value); + + // If there are any other stale entries in run, expunge them + if (slotToExpunge != staleSlot) + cleanSomeSlots(expungeStaleEntry(slotToExpunge), len); + } + + /** + * Expunge a stale entry by rehashing any possibly colliding entries + * lying between staleSlot and the next null slot. This also expunges + * any other stale entries encountered before the trailing null. See + * Knuth, Section 6.4 + * + * @param staleSlot index of slot known to have null key + * @return the index of the next null slot after staleSlot + * (all between staleSlot and this slot will have been checked + * for expunging). + */ + private int expungeStaleEntry(int staleSlot) { + Entry[] tab = table; + int len = tab.length; + + // expunge entry at staleSlot + tab[staleSlot].value = null; + tab[staleSlot] = null; + size--; + + // Rehash until we encounter null + Entry e; + int i; + for (i = nextIndex(staleSlot, len); + (e = tab[i]) != null; + i = nextIndex(i, len)) { + ThreadLocal k = e.get(); + if (k == null) { + e.value = null; + tab[i] = null; + size--; + } else { + int h = k.threadLocalHashCode & (len - 1); + if (h != i) { + tab[i] = null; + + // Unlike Knuth 6.4 Algorithm R, we must scan until + // null because multiple entries could have been stale. + while (tab[h] != null) + h = nextIndex(h, len); + tab[h] = e; + } + } + } + return i; + } + + /** + * Heuristically scan some cells looking for stale entries. + * This is invoked when either a new element is added, or + * another stale one has been expunged. It performs a + * logarithmic number of scans, as a balance between no + * scanning (fast but retains garbage) and a number of scans + * proportional to number of elements, that would find all + * garbage but would cause some insertions to take O(n) time. + * + * @param i a position known NOT to hold a stale entry. The + * scan starts at the element after i. + * + * @param n scan control: <tt>log2(n)</tt> cells are scanned, + * unless a stale entry is found, in which case + * <tt>log2(table.length)-1</tt> additional cells are scanned. + * When called from insertions, this parameter is the number + * of elements, but when from replaceStaleEntry, it is the + * table length. (Note: all this could be changed to be either + * more or less aggressive by weighting n instead of just + * using straight log n. But this version is simple, fast, and + * seems to work well.) + * + * @return true if any stale entries have been removed. + */ + private boolean cleanSomeSlots(int i, int n) { + boolean removed = false; + Entry[] tab = table; + int len = tab.length; + do { + i = nextIndex(i, len); + Entry e = tab[i]; + if (e != null && e.get() == null) { + n = len; + removed = true; + i = expungeStaleEntry(i); + } + } while ( (n >>>= 1) != 0); + return removed; + } + + /** + * Re-pack and/or re-size the table. First scan the entire + * table removing stale entries. If this doesn't sufficiently + * shrink the size of the table, double the table size. + */ + private void rehash() { + expungeStaleEntries(); + + // Use lower threshold for doubling to avoid hysteresis + if (size >= threshold - threshold / 4) + resize(); + } + + /** + * Double the capacity of the table. + */ + private void resize() { + Entry[] oldTab = table; + int oldLen = oldTab.length; + int newLen = oldLen * 2; + Entry[] newTab = new Entry[newLen]; + int count = 0; + + for (int j = 0; j < oldLen; ++j) { + Entry e = oldTab[j]; + if (e != null) { + ThreadLocal k = e.get(); + if (k == null) { + e.value = null; // Help the GC + } else { + int h = k.threadLocalHashCode & (newLen - 1); + while (newTab[h] != null) + h = nextIndex(h, newLen); + newTab[h] = e; + count++; + } + } + } + + setThreshold(newLen); + size = count; + table = newTab; + } + + /** + * Expunge all stale entries in the table. + */ + private void expungeStaleEntries() { + Entry[] tab = table; + int len = tab.length; + for (int j = 0; j < len; j++) { + Entry e = tab[j]; + if (e != null && e.get() == null) + expungeStaleEntry(j); + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-03-16 14:33:32
|
Revision: 5111 http://jnode.svn.sourceforge.net/jnode/?rev=5111&view=rev Author: crawley Date: 2009-03-16 14:33:29 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Style fixes Modified Paths: -------------- trunk/core/src/core/org/jnode/util/IOUtils.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java trunk/shell/src/shell/org/jnode/shell/io/BaseCommandIO.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java Modified: trunk/core/src/core/org/jnode/util/IOUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/IOUtils.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/core/src/core/org/jnode/util/IOUtils.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -27,10 +27,6 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.io.PipedReader; -import java.io.PipedWriter; import java.io.Reader; import java.io.Writer; import java.lang.reflect.Field; @@ -38,8 +34,6 @@ import java.security.PrivilegedAction; import org.apache.log4j.Logger; -import org.jnode.vm.annotation.DoPrivileged; -import org.jnode.vm.annotation.PrivilegedActionPragma; /** * Common utility code for higher-level operations on IO streams. Notwithstanding the Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjornePipeline.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -17,8 +17,9 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - package org.jnode.shell.bjorne; +package org.jnode.shell.bjorne; + import java.io.IOException; import java.util.HashMap; import java.util.Map; Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -83,12 +83,13 @@ @Override public CommandThread fork(CommandShell shell, final BjorneContext context) throws ShellException { - + CommandRunnable cr = new BjorneSubshellRunner(context) { @Override public int doRun() throws ShellException { return CaseCommandNode.this.execute(context); - }}; + } + }; return new CommandThreadImpl(cr, context.getName()); } } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ForCommandNode.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -83,7 +83,8 @@ @Override public int doRun() throws ShellException { return ForCommandNode.this.execute(context); - }}; + } + }; return new CommandThreadImpl(cr, context.getName()); } } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/FunctionDefinitionNode.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -67,7 +67,8 @@ @Override public int doRun() throws ShellException { return FunctionDefinitionNode.this.execute(context); - }}; + } + }; return new CommandThreadImpl(cr, context.getName()); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/IfCommandNode.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -94,7 +94,8 @@ @Override public int doRun() throws ShellException { return IfCommandNode.this.execute(context); - }}; + } + }; return new CommandThreadImpl(cr, context.getName()); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/ListCommandNode.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -112,7 +112,8 @@ @Override public int doRun() throws ShellException { return ListCommandNode.this.execute(context); - }}; + } + }; return new CommandThreadImpl(cr, context.getName()); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/LoopCommandNode.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -98,7 +98,8 @@ @Override public int doRun() throws ShellException { return LoopCommandNode.this.execute(context); - }}; + } + }; return new CommandThreadImpl(cr, context.getName()); } } Modified: trunk/shell/src/shell/org/jnode/shell/io/BaseCommandIO.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/io/BaseCommandIO.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/io/BaseCommandIO.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -29,6 +29,11 @@ import org.jnode.util.IOUtils; import org.jnode.util.ProxyStream; +/** + * Base class for the CommandIO implementations. + * + * @author cr...@jn... + */ abstract class BaseCommandIO implements CommandIO { private String assignedEncoding; @@ -86,13 +91,13 @@ } } - public synchronized final void close() throws IOException { + public final synchronized void close() throws IOException { doClose(); } abstract void doClose() throws IOException; - public synchronized final void flush() throws IOException { + public final synchronized void flush() throws IOException { doFlush(); } Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletProxyInputStream.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -106,7 +106,7 @@ @Override public void mark(int readLimit) { - getRealStream().mark(readLimit); + getRealStream().mark(readLimit); } @Override @@ -145,7 +145,8 @@ public InputStream getProxiedStream() throws ProxyStreamException { ProcletContext procletContext = ProcletContext.currentProcletContext(); - int pid = (procletContext == null) ? ProcletIOContext.GLOBAL_STREAM_ID : procletContext.getPid(); + int pid = (procletContext == null) ? + ProcletIOContext.GLOBAL_STREAM_ID : procletContext.getPid(); InputStream is = streamMap.get(pid); if (is == null) { throw new ProxyStreamException( Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-03-16 14:17:28 UTC (rev 5110) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-03-16 14:33:29 UTC (rev 5111) @@ -102,14 +102,14 @@ StringBuffer sb = new StringBuffer(20); while ((ch = r.read()) != marker) { switch (ch) { - case -1: - throw new TestSpecificationException("Encountered EOF in a " + marker + - "..." + marker + " sequence in script template"); - case '\n': - throw new TestSpecificationException("Encountered newline in a " + - marker + "..." + marker + " sequence in script template"); - default: - sb.append((char) ch); + case -1: + throw new TestSpecificationException("Encountered EOF in a " + marker + + "..." + marker + " sequence in script template"); + case '\n': + throw new TestSpecificationException("Encountered newline in a " + + marker + "..." + marker + " sequence in script template"); + default: + sb.append((char) ch); } } if (sb.length() == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-03-18 21:02:45
|
Revision: 5114 http://jnode.svn.sourceforge.net/jnode/?rev=5114&view=rev Author: lsantha Date: 2009-03-18 21:02:34 +0000 (Wed, 18 Mar 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/src/classpath/java/java/net/DatagramSocket.java trunk/core/src/classpath/java/java/net/ServerSocket.java trunk/core/src/classpath/java/java/net/Socket.java Added Paths: ----------- trunk/core/src/openjdk/java/java/net/Inet4Address.java trunk/core/src/openjdk/java/java/net/Inet4AddressImpl.java trunk/core/src/openjdk/java/java/net/Inet6Address.java trunk/core/src/openjdk/java/java/net/Inet6AddressImpl.java trunk/core/src/openjdk/java/java/net/InetAddress.java trunk/core/src/openjdk/java/java/net/InetAddressImpl.java trunk/core/src/openjdk/java/java/net/InetSocketAddress.java trunk/core/src/openjdk/vm/java/net/NativeInet4Address.java trunk/core/src/openjdk/vm/java/net/NativeInet4AddressImpl.java trunk/core/src/openjdk/vm/java/net/NativeInet6Address.java trunk/core/src/openjdk/vm/java/net/NativeInet6AddressImpl.java trunk/core/src/openjdk/vm/java/net/NativeInetAddress.java trunk/core/src/openjdk/vm/java/net/NativeInetAddressImplFactory.java Removed Paths: ------------- trunk/core/src/classpath/java/java/net/Inet4Address.java trunk/core/src/classpath/java/java/net/Inet6Address.java trunk/core/src/classpath/java/java/net/InetAddress.java trunk/core/src/classpath/java/java/net/InetSocketAddress.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/all/conf/openjdk-annotations.properties 2009-03-18 21:02:34 UTC (rev 5114) @@ -11,6 +11,8 @@ java/awt/Toolkit.class=SharedStatics java/lang/ThreadLocal.class=SharedStatics java/lang/Throwable.class=MagicPermission +java/net/InetAddress.class=SharedStatics +java/net/URLConnection.class=SharedStatics java/util/Currency.class=SharedStatics java/util/concurrent/locks/LockSupport.class=SharedStatics sun/awt/AppContext.class=SharedStatics Modified: trunk/core/src/classpath/java/java/net/DatagramSocket.java =================================================================== --- trunk/core/src/classpath/java/java/net/DatagramSocket.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/DatagramSocket.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -317,7 +317,7 @@ } catch (SecurityException e) { - localAddr = InetAddress.ANY_IF; + localAddr = NativeInetAddress.ANY_IF; } catch (SocketException e) { @@ -673,7 +673,7 @@ s.checkListen(port); if (addr == null) - addr = InetAddress.ANY_IF; + addr = NativeInetAddress.ANY_IF; try { Deleted: trunk/core/src/classpath/java/java/net/Inet4Address.java =================================================================== --- trunk/core/src/classpath/java/java/net/Inet4Address.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/Inet4Address.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -1,233 +0,0 @@ -/* Inet4Address.java -- - Copyright (C) 2002, 2003, 2004, 2005 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 java.net; - -import java.io.ObjectStreamException; - -/* - * Written using on-line Java Platform 1.4 API Specification and - * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt), - * RFC 1918 (http://www.ietf.org/rfc/rfc1918.txt), - * RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt) - * - * @author Michael Koch - * @status Believed complete and correct. - */ -public final class Inet4Address extends InetAddress -{ - /** - * For compatability with Sun's JDK 1.4.2 rev. 5 - */ - static final long serialVersionUID = 3286316764910316507L; - - /** - * needed for serialization - */ - private Object writeReplace() throws ObjectStreamException - { - return new InetAddress(addr, hostName); - } - - /** - * Initializes this object's addr instance variable from the passed in - * byte array. Note that this constructor is protected and is called - * only by static methods in this class. - * - * @param addr The IP number of this address as an array of bytes - * @param host The hostname of this IP address. - */ - Inet4Address(byte[] addr, String host) - { - super(addr, host); - } - - /** - * Checks if the address is a multicast address - * - * @since 1.1 - */ - public boolean isMulticastAddress() - { - return super.isMulticastAddress(); - } - - /** - * Checks if this address is a loopback address - */ - public boolean isLoopbackAddress() - { - return super.isLoopbackAddress(); - } - - /** - * Checks if this address is a wildcard address - * - * @since 1.4 - */ - public boolean isAnyLocalAddress() - { - return super.isAnyLocalAddress(); - } - - /** - * Checks if this address is a link local address - * - * @since 1.4 - */ - public boolean isLinkLocalAddress() - { - return super.isLinkLocalAddress(); - } - - /** - * Checks if this address is a site local address - * - * @since 1.4 - */ - public boolean isSiteLocalAddress() - { - return super.isSiteLocalAddress(); - } - - /** - * Checks if this multicast address has global scope - * - * @since 1.4 - */ - public boolean isMCGlobal() - { - return super.isMCGlobal(); - } - - /** - * Checks if this multicast address has node scope - * - * @since 1.4 - */ - public boolean isMCNodeLocal() - { - return super.isMCNodeLocal(); - } - - /** - * Checks if this multicast address has link scope - * - * @since 1.4 - */ - public boolean isMCLinkLocal() - { - return super.isMCLinkLocal(); - } - - /** - * Checks if this multicast address has site scope - * - * @since 1.4 - */ - public boolean isMCSiteLocal() - { - return super.isMCSiteLocal(); - } - - /** - * Checks if this multicast address has organization scope - * - * @since 1.4 - */ - public boolean isMCOrgLocal() - { - return super.isMCOrgLocal(); - } - - /** - * Returns the address of the current instance - */ - public byte[] getAddress() - { - return (byte[]) addr.clone(); - } - - /** - * Returns the address as string - * - * @since 1.0.2 - */ - public String getHostAddress() - { - return super.getHostAddress(); - } - - /** - * Computes the hashcode of the instance - */ - public int hashCode() - { - int hash = 0; - int len = addr.length; - int i = len > 4 ? len - 4 : 0; - - for (; i < len; i++) - hash = (hash << 8) | (addr[i] & 0xFF); - - return hash; - } - - /** - * Compare the current Inet4Address instance with obj - * - * @param obj Object to compare with - */ - public boolean equals(Object obj) - { - if (! (obj instanceof InetAddress)) - return false; - - byte[] addr1 = addr; - byte[] addr2 = ((InetAddress) obj).addr; - - if (addr1.length != addr2.length) - return false; - - for (int i = addr1.length; --i >= 0;) - if (addr1[i] != addr2[i]) - return false; - - return true; - } -} Deleted: trunk/core/src/classpath/java/java/net/Inet6Address.java =================================================================== --- trunk/core/src/classpath/java/java/net/Inet6Address.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/Inet6Address.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -1,422 +0,0 @@ -/* Inet6Address.java -- - Copyright (C) 2002, 2003, 2004 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 java.net; - -import java.util.Arrays; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.IOException; - -/* - * Written using on-line Java Platform 1.4 API Specification and - * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt) - * - * @author Michael Koch - * @status Updated to 1.5. Serialization compatibility is tested. - */ -public final class Inet6Address extends InetAddress -{ - static final long serialVersionUID = 6880410070516793377L; - - /** - * Needed for serialization - */ - byte[] ipaddress; - - /** - * The scope ID, if any. - * @since 1.5 - * @serial - */ - private int scope_id; - - /** - * The scope ID, if any. - * @since 1.5 - * @serial - */ - private boolean scope_id_set; - - /** - * Whether ifname is set or not. - * @since 1.5 - * @serial - */ - private boolean scope_ifname_set; - - /** - * Name of the network interface, used only by the serialization methods - * @since 1.5 - * @serial - */ - private String ifname; - - /** - * Scope network interface, or <code>null</code>. - */ - private transient NetworkInterface nif; - - /** - * Create an Inet6Address object - * - * @param addr The IP address - * @param host The hostname - */ - Inet6Address(byte[] addr, String host) - { - super(addr, host); - // Super constructor clones the addr. Get a reference to the clone. - this.ipaddress = this.addr; - ifname = null; - scope_ifname_set = scope_id_set = false; - scope_id = 0; - nif = null; - } - - /** - * Utility routine to check if the InetAddress is an IP multicast address - * - * @since 1.1 - */ - public boolean isMulticastAddress() - { - return ipaddress[0] == 0xFF; - } - - /** - * Utility routine to check if the InetAddress in a wildcard address - * - * @since 1.4 - */ - public boolean isAnyLocalAddress() - { - byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - return Arrays.equals(ipaddress, anylocal); - } - - /** - * Utility routine to check if the InetAddress is a loopback address - * - * @since 1.4 - */ - public boolean isLoopbackAddress() - { - byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; - - return Arrays.equals(ipaddress, loopback); - } - - /** - * Utility routine to check if the InetAddress is an link local address - * - * @since 1.4 - */ - public boolean isLinkLocalAddress() - { - return ipaddress[0] == 0xFA; - } - - /** - * Utility routine to check if the InetAddress is a site local address - * - * @since 1.4 - */ - public boolean isSiteLocalAddress() - { - return ipaddress[0] == 0xFB; - } - - /** - * Utility routine to check if the multicast address has global scope - * - * @since 1.4 - */ - public boolean isMCGlobal() - { - if (! isMulticastAddress()) - return false; - - return (ipaddress[1] & 0x0F) == 0xE; - } - - /** - * Utility routine to check if the multicast address has node scope - * - * @since 1.4 - */ - public boolean isMCNodeLocal() - { - if (! isMulticastAddress()) - return false; - - return (ipaddress[1] & 0x0F) == 0x1; - } - - /** - * Utility routine to check if the multicast address has link scope - * - * @since 1.4 - */ - public boolean isMCLinkLocal() - { - if (! isMulticastAddress()) - return false; - - return (ipaddress[1] & 0x0F) == 0x2; - } - - /** - * Utility routine to check if the multicast address has site scope - * - * @since 1.4 - */ - public boolean isMCSiteLocal() - { - if (! isMulticastAddress()) - return false; - - return (ipaddress[1] & 0x0F) == 0x5; - } - - /** - * Utility routine to check if the multicast address has organization scope - * - * @since 1.4 - */ - public boolean isMCOrgLocal() - { - if (! isMulticastAddress()) - return false; - - return (ipaddress[1] & 0x0F) == 0x8; - } - - /** - * Returns the raw IP address of this InetAddress object. The result is in - * network byte order: the highest order byte of the address is i - * n getAddress()[0] - */ - public byte[] getAddress() - { - return (byte[]) ipaddress.clone(); - } - - /** - * Creates a scoped Inet6Address where the scope has an integer id. - * - * @throws UnkownHostException if the address is an invalid number of bytes. - * @since 1.5 - */ - public static Inet6Address getByAddress(String host, byte[] addr, - int scopeId) - throws UnknownHostException - { - if( addr.length != 16 ) - throw new UnknownHostException("Illegal address length: " + addr.length - + " bytes."); - Inet6Address ip = new Inet6Address( addr, host ); - ip.scope_id = scopeId; - ip.scope_id_set = true; - return ip; - } - - /** - * Creates a scoped Inet6Address where the scope is a given - * NetworkInterface. - * - * @throws UnkownHostException if the address is an invalid number of bytes. - * @since 1.5 - */ - public static Inet6Address getByAddress(String host, byte[] addr, - NetworkInterface nif) - throws UnknownHostException - { - if( addr.length != 16 ) - throw new UnknownHostException("Illegal address length: " + addr.length - + " bytes."); - Inet6Address ip = new Inet6Address( addr, host ); - ip.nif = nif; - - return ip; - } - - /** - * Returns the <code>NetworkInterface</code> of the address scope - * if it is a scoped address and the scope is given in the form of a - * NetworkInterface. - * (I.e. the address was created using the - * getByAddress(String, byte[], NetworkInterface) method) - * Otherwise this method returns <code>null</code>. - * @since 1.5 - */ - public NetworkInterface getScopedInterface() - { - return nif; - } - - /** - * Returns the scope ID of the address scope if it is a scoped adress using - * an integer to identify the scope. - * - * Otherwise this method returns 0. - * @since 1.5 - */ - public int getScopeId() - { - // check scope_id_set because some JDK-serialized objects seem to have - // scope_id set to a nonzero value even when scope_id_set == false - if( scope_id_set ) - return scope_id; - return 0; - } - - /** - * Returns the IP address string in textual presentation - */ - public String getHostAddress() - { - StringBuffer sbuf = new StringBuffer(40); - - for (int i = 0; i < 16; i += 2) - { - int x = ((ipaddress[i] & 0xFF) << 8) | (ipaddress[i + 1] & 0xFF); - - if (i > 0) - sbuf.append(':'); - - sbuf.append(Integer.toHexString(x)); - } - if( nif != null ) - sbuf.append( "%" + nif.getName() ); - else if( scope_id_set ) - sbuf.append( "%" + scope_id ); - - return sbuf.toString(); - } - - /** - * Returns a hashcode for this IP address - * (The hashcode is independent of scope) - */ - public int hashCode() - { - return super.hashCode(); - } - - /** - * Compares this object against the specified object - */ - public boolean equals(Object obj) - { - if (! (obj instanceof Inet6Address)) - return false; - - Inet6Address ip = (Inet6Address)obj; - if (ipaddress.length != ip.ipaddress.length) - return false; - - for (int i = 0; i < ip.ipaddress.length; i++) - if (ipaddress[i] != ip.ipaddress[i]) - return false; - - if( ip.nif != null && nif != null ) - return nif.equals( ip.nif ); - if( ip.nif != nif ) - return false; - if( ip.scope_id_set != scope_id_set ) - return false; - if( scope_id_set ) - return (scope_id == ip.scope_id); - return true; - } - - /** - * Utility routine to check if the InetAddress is an - * IPv4 compatible IPv6 address - * - * @since 1.4 - */ - public boolean isIPv4CompatibleAddress() - { - if (ipaddress[0] != 0x00 || ipaddress[1] != 0x00 || ipaddress[2] != 0x00 - || ipaddress[3] != 0x00 || ipaddress[4] != 0x00 - || ipaddress[5] != 0x00 || ipaddress[6] != 0x00 - || ipaddress[7] != 0x00 || ipaddress[8] != 0x00 - || ipaddress[9] != 0x00 || ipaddress[10] != 0x00 - || ipaddress[11] != 0x00) - return false; - - return true; - } - - /** - * Required for 1.5-compatible serialization. - * @since 1.5 - */ - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - s.defaultReadObject(); - try - { - if( scope_ifname_set ) - nif = NetworkInterface.getByName( ifname ); - } - catch( SocketException se ) - { - // FIXME: Ignore this? or throw an IOException? - } - } - - /** - * Required for 1.5-compatible serialization. - * @since 1.5 - */ - private void writeObject(ObjectOutputStream s) - throws IOException - { - if( nif != null ) - { - ifname = nif.getName(); - scope_ifname_set = true; - } - s.defaultWriteObject(); - } -} Deleted: trunk/core/src/classpath/java/java/net/InetAddress.java =================================================================== --- trunk/core/src/classpath/java/java/net/InetAddress.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/InetAddress.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -1,698 +0,0 @@ -/* InetAddress.java -- Class to model an Internet address - Copyright (C) 1998, 1999, 2002, 2004, 2005 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 java.net; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.util.StringTokenizer; - -/** - * This class models an Internet address. It does not have a public - * constructor. Instead, new instances of this objects are created - * using the static methods getLocalHost(), getByName(), and - * getAllByName(). - * - * <p>This class fulfills the function of the C style functions gethostname(), - * gethostbyname(), and gethostbyaddr(). It resolves Internet DNS names - * into their corresponding numeric addresses and vice versa.</p> - * - * @author Aaron M. Renn (ar...@ur...) - * @author Per Bothner - * - * @specnote This class is not final since JK 1.4 - */ -public class InetAddress implements Serializable -{ - private static final long serialVersionUID = 3286316764910316507L; - - /** - * The special IP address INADDR_ANY. - */ - private static InetAddress inaddr_any; - - /** - * Dummy InetAddress, used to bind socket to any (all) network interfaces. - */ - static InetAddress ANY_IF; - - /** - * Stores static localhost address object. - */ - static InetAddress LOCALHOST; - - static - { - // precompute the ANY_IF address - try - { - ANY_IF = getInaddrAny(); - - byte[] ip_localhost = { 127, 0, 0, 1 }; - LOCALHOST = new Inet4Address(ip_localhost, "localhost"); - } - catch (UnknownHostException uhe) - { - // Hmmm, make one up and hope that it works. - byte[] zeros = { 0, 0, 0, 0 }; - ANY_IF = new Inet4Address(zeros, "0.0.0.0"); - } - } - - /** - * The Serialized Form specifies that an int 'address' is saved/restored. - * This class uses a byte array internally so we'll just do the conversion - * at serialization time and leave the rest of the algorithm as is. - */ - private int address; - - /** - * An array of octets representing an IP address. - */ - transient byte[] addr; - - /** - * The name of the host for this address. - */ - String hostName; - - /** - * The field 'family' seems to be the AF_ value. - * FIXME: Much of the code in the other java.net classes does not make - * use of this family field. A better implementation would be to make - * use of getaddrinfo() and have other methods just check the family - * field rather than examining the length of the address each time. - */ - int family; - - /** - * Initializes this object's addr instance variable from the passed in - * byte array. Note that this constructor is protected and is called - * only by static methods in this class. - * - * @param ipaddr The IP number of this address as an array of bytes - * @param hostname The hostname of this IP address. - */ - InetAddress(byte[] ipaddr, String hostname) - { - addr = (null == ipaddr) ? null : (byte[]) ipaddr.clone(); - hostName = hostname; - - family = 2; /* AF_INET */ - } - - /** - * Returns true if this address is a multicast address, false otherwise. - * An address is multicast if the high four bits are "1110". These are - * also known as "Class D" addresses. - * - * @return true if mulitcast, false if not - * - * @since 1.1 - */ - public boolean isMulticastAddress() - { - // Mask against high order bits of 1110 - if (addr.length == 4) - return (addr[0] & 0xf0) == 0xe0; - - return false; - } - - /** - * Utility routine to check if the InetAddress in a wildcard address - * - * @since 1.4 - */ - public boolean isAnyLocalAddress() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - return equals(ANY_IF); - } - - /** - * Utility routine to check if the InetAddress is a loopback address - * - * @since 1.4 - */ - public boolean isLoopbackAddress() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - return (addr[0] & 0xff) == 0x7f; - } - - /** - * Utility routine to check if InetAddress is a link local address - * - * @since 1.4 - */ - public boolean isLinkLocalAddress() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - // XXX: This seems to not exist with IPv4 addresses - return false; - } - - /** - * Utility routine to check if InetAddress is a site local address - * - * @since 1.4 - */ - public boolean isSiteLocalAddress() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - - // 10.0.0.0/8 - if ((addr[0] & 0xff) == 0x0a) - return true; - - // 172.16.0.0/12 - if ((addr[0] & 0xff) == 0xac && (addr[1] & 0xf0) == 0x10) - return true; - - // 192.168.0.0/16 - if ((addr[0] & 0xff) == 0xc0 && (addr[1] & 0xff) == 0xa8) - return true; - - // XXX: Do we need to check more addresses here ? - return false; - } - - /** - * Utility routine to check if InetAddress is a global multicast address - * - * @since 1.4 - */ - public boolean isMCGlobal() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - // XXX: This seems to not exist with IPv4 addresses - return false; - } - - /** - * Utility routine to check if InetAddress is a node local multicast address. - * - * @since 1.4 - */ - public boolean isMCNodeLocal() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - // XXX: This seems to not exist with IPv4 addresses - return false; - } - - /** - * Utility routine to check if InetAddress is a link local multicast address. - * - * @since 1.4 - */ - public boolean isMCLinkLocal() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - if (! isMulticastAddress()) - return false; - - return ((addr[0] & 0xff) == 0xe0 - && (addr[1] & 0xff) == 0x00 - && (addr[2] & 0xff) == 0x00); - } - - /** - * Utility routine to check if InetAddress is a site local multicast address. - * - * @since 1.4 - */ - public boolean isMCSiteLocal() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - // XXX: This seems to not exist with IPv4 addresses - return false; - } - - /** - * Utility routine to check if InetAddress is a organization local - * multicast address. - * - * @since 1.4 - */ - public boolean isMCOrgLocal() - { - // This is the IPv4 implementation. - // Any class derived from InetAddress should override this. - // XXX: This seems to not exist with IPv4 addresses - return false; - } - - /** - * Returns the hostname for this address. This will return the IP address - * as a String if there is no hostname available for this address - * - * @return The hostname for this address - */ - public String getHostName() - { - if (hostName != null) - return hostName; - - try - { - hostName = VMInetAddress.getHostByAddr(addr); - return hostName; - } - catch (UnknownHostException e) - { - return getHostAddress(); - } - } - - //jnode - String getHostName(boolean check){ - return getHostName(); - } - - /** - * Returns the canonical hostname represented by this InetAddress - * - * @since 1.4 - */ - public String getCanonicalHostName() - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - { - try - { - sm.checkConnect(hostName, -1); - } - catch (SecurityException e) - { - return getHostAddress(); - } - } - - // Try to find the FDQN now - InetAddress address; - byte[] ipaddr = getAddress(); - - if (ipaddr.length == 16) - address = new Inet6Address(getAddress(), null); - else - address = new Inet4Address(getAddress(), null); - - return address.getHostName(); - } - - /** - * Returns the IP address of this object as a byte array. - * - * @return IP address - */ - public byte[] getAddress() - { - // An experiment shows that JDK1.2 returns a different byte array each - // time. This makes sense, in terms of security. - return (byte[]) addr.clone(); - } - - /** - * Returns the IP address of this object as a String. The address is in - * the dotted octet notation, for example, "127.0.0.1". - * - * @return The IP address of this object in String form - * - * @since 1.0.2 - */ - public String getHostAddress() - { - StringBuffer sb = new StringBuffer(40); - - int len = addr.length; - int i = 0; - - for ( ; ; ) - { - sb.append(addr[i] & 0xff); - i++; - - if (i == len) - break; - - sb.append('.'); - } - - return sb.toString(); - } - - /** - * Returns a hash value for this address. Useful for creating hash - * tables. Overrides Object.hashCode() - * - * @return A hash value for this address. - */ - public int hashCode() - { - // There hashing algorithm is not specified, but a simple experiment - // shows that it is equal to the address, as a 32-bit big-endian integer. - int hash = 0; - int len = addr.length; - int i = len > 4 ? len - 4 : 0; - - for (; i < len; i++) - hash = (hash << 8) | (addr[i] & 0xff); - - return hash; - } - - /** - * Tests this address for equality against another InetAddress. The two - * addresses are considered equal if they contain the exact same octets. - * This implementation overrides Object.equals() - * - * @param obj The address to test for equality - * - * @return true if the passed in object's address is equal to this one's, - * false otherwise - */ - public boolean equals(Object obj) - { - if (! (obj instanceof InetAddress)) - return false; - - // "The Java Class Libraries" 2nd edition says "If a machine has - // multiple names instances of InetAddress for different name of - // that same machine are not equal. This is because they have - // different host names." This violates the description in the - // JDK 1.2 API documentation. A little experimentation - // shows that the latter is correct. - byte[] addr2 = ((InetAddress) obj).addr; - - if (addr.length != addr2.length) - return false; - - for (int i = 0; i < addr.length; i++) - if (addr[i] != addr2[i]) - return false; - - return true; - } - - /** - * Converts this address to a String. This string contains the IP in - * dotted decimal form. For example: "127.0.0.1" This method is equivalent - * to getHostAddress() and overrides Object.toString() - * - * @return This address in String form - */ - public String toString() - { - String addr = getHostAddress(); - String host = (hostName != null) ? hostName : ""; - return host + "/" + addr; - } - - /** - * Returns an InetAddress object given the raw IP address. - * - * The argument is in network byte order: the highest order byte of the - * address is in getAddress()[0]. - * - * @param addr The IP address to create the InetAddress object from - * - * @exception UnknownHostException If IP address has illegal length - * - * @since 1.4 - */ - public static InetAddress getByAddress(byte[] addr) - throws UnknownHostException - { - return getByAddress(null, addr); - } - - /** - * Creates an InetAddress based on the provided host name and IP address. - * No name service is checked for the validity of the address. - * - * @param host The hostname of the InetAddress object to create - * @param addr The IP address to create the InetAddress object from - * - * @exception UnknownHostException If IP address is of illegal length - * - * @since 1.4 - */ - public static InetAddress getByAddress(String host, byte[] addr) - throws UnknownHostException - { - if (addr.length == 4) - return new Inet4Address(addr, host); - - if (addr.length == 16) - return new Inet6Address(addr, host); - - throw new UnknownHostException("IP address has illegal length"); - } - - /** - * If hostname is a valid numeric IP address, return the numeric address. - * Otherwise, return null. - * - * @param hostname the name of the host - */ - private static byte[] aton(String hostname) - { - StringTokenizer st = new StringTokenizer(hostname, "."); - - if (st.countTokens() == 4) - { - int index; - byte[] address = new byte[4]; - - for (index = 0; index < 4; index++) - { - try - { - short n = Short.parseShort(st.nextToken()); - - if ((n < 0) || (n > 255)) - break; - - address[index] = (byte) n; - } - catch (NumberFormatException e) - { - break; - } - } - - if (index == 4) - return address; - } - - return null; - } - - /** - * Returns an InetAddress object representing the IP address of the given - * hostname. This name can be either a hostname such as "www.urbanophile.com" - * or an IP address in dotted decimal format such as "127.0.0.1". If the - * hostname is null or "", the hostname of the local machine is supplied by - * default. This method is equivalent to returning the first element in - * the InetAddress array returned from GetAllByName. - * - * @param hostname The name of the desired host, or null for the local - * loopback address. - * - * @return The address of the host as an InetAddress object. - * - * @exception UnknownHostException If no IP address for the host could - * be found - * @exception SecurityException If a security manager exists and its - * checkConnect method doesn't allow the operation - */ - public static InetAddress getByName(String hostname) - throws UnknownHostException - { - InetAddress[] addresses = getAllByName(hostname); - return addresses[0]; - } - - /** - * Returns an array of InetAddress objects representing all the host/ip - * addresses of a given host, given the host's name. This name can be - * either a hostname such as "www.urbanophile.com" or an IP address in - * dotted decimal format such as "127.0.0.1". If the value is null, the - * hostname of the local machine is supplied by default. - * - * @param hostname The name of the desired host, or null for the - * local loopback address. - * - * @return All addresses of the host as an array of InetAddress objects. - * - * @exception UnknownHostException If no IP address for the host could - * be found - * @exception SecurityException If a security manager exists and its - * checkConnect method doesn't allow the operation - */ - public static InetAddress[] getAllByName(String hostname) - throws UnknownHostException - { - return getAllByName0(hostname, true); - } - - //jnode - static InetAddress[] getAllByName0(String hostname, boolean check) - throws UnknownHostException - { - if(check){ - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkConnect(hostname, -1); - } - - InetAddress[] addresses; - - if (hostname != null) - hostname = hostname.trim(); - - // Default to current host if necessary - if (hostname == null || hostname.equals("")) - { - addresses = new InetAddress[1]; - addresses[0] = LOCALHOST; - return addresses; - } - - // Not in cache, try the lookup - byte[][] iplist = VMInetAddress.getHostByName(hostname); - - if (iplist.length == 0) - throw new UnknownHostException(hostname); - - addresses = new InetAddress[iplist.length]; - - for (int i = 0; i < iplist.length; i++) - { - if (iplist[i].length != 4) - throw new UnknownHostException(hostname); - - addresses[i] = new Inet4Address(iplist[i], hostname); - } - - return addresses; - } - - /** - * Returns the special address INADDR_ANY used for binding to a local - * port on all IP addresses hosted by a the local host. - * - * @return An InetAddress object representing INDADDR_ANY - * - * @exception UnknownHostException If an error occurs - */ - static InetAddress getInaddrAny() throws UnknownHostException - { - if (inaddr_any == null) - { - byte[] tmp = VMInetAddress.lookupInaddrAny(); - inaddr_any = new Inet4Address(tmp, null); - inaddr_any.hostName = inaddr_any.getHostName(); - } - - return inaddr_any; - } - - /** - * Returns an InetAddress object representing the address of the current - * host. - * - * @return The local host's address - * - * @exception UnknownHostException If no IP address for the host could - * be found - */ - public static InetAddress getLocalHost() throws UnknownHostException - { - String hostname = VMInetAddress.getLocalHostname(); - return getByName(hostname); - } - - /* - * Needed for serialization - */ - private Object readResolve() throws ObjectStreamException - { - return new Inet4Address(addr, hostName); - } - - private void readObject(ObjectInputStream ois) - throws IOException, ClassNotFoundException - { - ois.defaultReadObject(); - addr = new byte[4]; - addr[3] = (byte) address; - - for (int i = 2; i >= 0; --i) - addr[i] = (byte) (address >>= 8); - - family = 2; /* AF_INET */ - } - - private void writeObject(ObjectOutputStream oos) throws IOException - { - // Build a 32 bit address from the last 4 bytes of a 4 byte IPv4 address - // or a 16 byte IPv6 address. - int len = addr.length; - int i = len - 4; - - for (; i < len; i++) - address = address << 8 | (addr[i] & 0xff); - - oos.defaultWriteObject(); - } -} Deleted: trunk/core/src/classpath/java/java/net/InetSocketAddress.java =================================================================== --- trunk/core/src/classpath/java/java/net/InetSocketAddress.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/InetSocketAddress.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -1,261 +0,0 @@ -/* InetSocketAddress.java -- - Copyright (C) 2002, 2006 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 java.net; - - -/** - * InetSocketAddress instances represent socket addresses - * in the java.nio package. They encapsulate a InetAddress and - * a port number. - * - * @since 1.4 - */ -public class InetSocketAddress extends SocketAddress -{ - /** - * Compatible with JDK 1.4+ - */ - private static final long serialVersionUID = 5076001401234631237L; - - /** - * Name of host. - */ - private String hostname; - - /** - * Address of host. - */ - private InetAddress addr; - - /** - * Port of host. - */ - private int port; - - /** - * Constructs an InetSocketAddress instance. - * - * @param addr Address of the socket - * @param port Port if the socket - * - * @exception IllegalArgumentException If the port number is illegel - */ - public InetSocketAddress(InetAddress addr, int port) - throws IllegalArgumentException - { - if (port < 0 || port > 65535) - throw new IllegalArgumentException("Bad port number: " + port); - - if (addr == null) - addr = InetAddress.ANY_IF; - - this.addr = addr; - this.port = port; - } - - /** - * Constructs an InetSocketAddress instance. - * - * @param port Port if the socket - * - * @exception IllegalArgumentException If the port number is illegal - */ - public InetSocketAddress(int port) throws IllegalArgumentException - { - this((InetAddress) null, port); - } - - /** - * Constructs an InetSocketAddress instance. - * - * @param hostname The hostname for the socket address - * @param port The port for the socket address - * - * @exception IllegalArgumentException If the port number is illegal or - * the hostname argument is null - */ - public InetSocketAddress(String hostname, int port) - { - this(hostname, port, true); - } - - /** - * Constructs an InetSocketAddress instance. - * - * @param hostname The hostname for the socket address - * @param port The port for the socket address - * @param resolve <code>true</code> if the address has to be resolved, - * <code>false</code> otherwise - * - * @exception IllegalArgumentException If the port number is illegal or - * the hostname argument is null - */ - private InetSocketAddress(String hostname, int port, boolean resolve) - { - if (hostname == null) - throw new IllegalArgumentException("Null host name value"); - - if (port < 0 || port > 65535) - throw new IllegalArgumentException("Bad port number: " + port); - - this.port = port; - this.hostname = hostname; - this.addr = null; - - if (resolve) - { - try - { - this.addr = InetAddress.getByName(hostname); - } - catch (Exception e) // UnknownHostException, SecurityException - { - // Do nothing here. this.addr is already set to null. - } - } - - } - - /** - * Creates an unresolved <code>InetSocketAddress</code> object. - * - * @param hostname The hostname for the socket address - * @param port The port for the socket address - * - * @exception IllegalArgumentException If the port number is illegal or - * the hostname argument is null - * - * @since 1.5 - */ - public static InetSocketAddress createUnresolved(String hostname, int port) - { - return new InetSocketAddress(hostname, port, false); - } - - /** - * Test if obj is a <code>InetSocketAddress</code> and - * has the same address and port - * - * @param obj The obj to compare this address with. - * - * @return True if obj is equal. - */ - public final boolean equals(Object obj) - { - // InetSocketAddress objects are equal when addr and port are equal. - // The hostname may differ. - if (obj instanceof InetSocketAddress) - { - InetSocketAddress sa = (InetSocketAddress) obj; - - if (addr == null && sa.addr != null) - return false; - else if (addr == null && sa.addr == null) // we know hostname != null - return hostname.equals(sa.hostname) && sa.port == port; - else - return addr.equals(sa.addr) && sa.port == port; - } - - return false; - } - - /** - * Returns the <code>InetAddress</code> or - * <code>null</code> if its unresolved - * - * @return The IP address of this address. - */ - public final InetAddress getAddress() - { - return addr; - } - - /** - * Returns <code>hostname</code> - * - * @return The hostname of this address. - */ - public final String getHostName() - { - if (hostname == null) // we know addr != null - hostname = addr.getHostName(); - - return hostname; - } - - /** - * Returns the <code>port</code> - * - * @return The port of this address. - */ - public final int getPort() - { - return port; - } - - /** - * Returns the hashcode of the <code>InetSocketAddress</code> - * - * @return The hashcode for this address. - */ - public final int hashCode() - { - return port + addr.hashCode(); - } - - /** - * Checks wether the address has been resolved or not - * - * @return True if address is unresolved. - */ - public final boolean isUnresolved() - { - return addr == null; - } - - /** - * Returns the <code>InetSocketAddress</code> as string - * - * @return A string representation of this address. - */ - public String toString() - { - // Note: if addr is null, then hostname != null. - return (addr == null ? hostname : addr.toString()) + ":" + port; - } -} Modified: trunk/core/src/classpath/java/java/net/ServerSocket.java =================================================================== --- trunk/core/src/classpath/java/java/net/ServerSocket.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/ServerSocket.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -233,7 +233,7 @@ // Initialize addr with 0.0.0.0. if (addr == null) - addr = InetAddress.ANY_IF; + addr = NativeInetAddress.ANY_IF; try { Modified: trunk/core/src/classpath/java/java/net/Socket.java =================================================================== --- trunk/core/src/classpath/java/java/net/Socket.java 2009-03-17 13:25:49 UTC (rev 5113) +++ trunk/core/src/classpath/java/java/net/Socket.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -354,7 +354,7 @@ // XXX: JDK 1.4.1 API documentation says that if bindpoint is null the // socket will be bound to an ephemeral port and a valid local address. if (bindpoint == null) - bindpoint = new InetSocketAddress(InetAddress.ANY_IF, 0); + bindpoint = new InetSocketAddress(NativeInetAddress.ANY_IF, 0); if (! (bindpoint instanceof InetSocketAddress)) throw new IllegalArgumentException(); @@ -479,7 +479,7 @@ public InetAddress getLocalAddress() { if (! isBound()) - return InetAddress.ANY_IF; + return NativeInetAddress.ANY_IF; InetAddress addr = null; Added: trunk/core/src/openjdk/java/java/net/Inet4Address.java =================================================================== --- trunk/core/src/openjdk/java/java/net/Inet4Address.java (rev 0) +++ trunk/core/src/openjdk/java/java/net/Inet4Address.java 2009-03-18 21:02:34 UTC (rev 5114) @@ -0,0 +1,374 @@ +/* + * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.net; + +import java.security.AccessController; +import java.io.ObjectStreamException; +import sun.security.action.*; + +/** + * This class represents an Internet Protocol version 4 (IPv4) address. + * Defined by <a href="http://www.ietf.org/rfc/rfc790.txt"> + * <i>RFC 790: Assigned Numbers</i></a>, + * <a href="http://www.ietf.org/rfc/rfc1918.txt"> + * <i>RFC 1918: Address Allocation for Private Internets</i></a>, + * and <a href="http://www.ietf.org/rfc/rfc2365.txt"><i>RFC 2365: + * Administratively Scoped IP Multicast</i></a> + * + * <h4> <A NAME="format">Textual representation of IP addresses</a> </h4> + * + * Textual representation of IPv4 address used as input to methods + * takes one of the following forms: + * + * <blockquote><table cellpadding=0 cellspacing=0 summary="layout"> + * <tr><td><tt>d.d.d.d</tt></td></tr> + * <tr><td><tt>d.d.d</tt></td></tr> + * <tr><td><tt>d.d</tt></td></tr> + * <tr><td><tt>d</tt></td></tr> + * </table></blockquote> + * + * <p> When four parts are specified, each is interpreted as a byte of + * data and assigned, from left to right, to the four bytes of an IPv4 + * address. + + * <p> When a three part address is specified, the last part is + * interpreted as a 16-bit quantity and placed in the right most two + * bytes of the network address. This makes the three part address + * format convenient for specifying Class B net- work addresses as + * 128.net.host. + * + * <p> When a two part address is supplied, the last part is + * interpreted as a 24-bit quantity and placed in the right most three + * bytes of the network address. This makes the two part address + * format convenient for specifying Class A network addresses as + * net.host. + * + * <p> When only one part is given, the value is stored directly in + * the network address without any byte rearrangement. + * + * <p> For methods that return a textual representation as output + * value, the first form, i.e. a dotted-quad string, is used. + * + * <h4> The Scope of a Multicast Address </h4> + * + * Historically the IPv4 TTL field in the IP header has doubled as a + * multicast scope field: a TTL of 0 means node-local, 1 means + * link-local, up through 32 means site-local, up through 64 means + * region-local, up through 128 means continent-local, and up through + * 255 are global. However, the administrative scoping is preferred. + * Please refer to <a href="http://www.ietf.org/rfc/rfc2365.txt"> + * <i>RFC 2365: Administratively Scoped IP Multicast</i></a> + * @since 1.4 + */ + +public final +class Inet4Address extends InetAddress { + final static int INADDRSZ = 4; + + /** use serialVersionUID from InetAddress, but Inet4Address instance + * is always replaced by an InetAddress instance before being + * serialized */ + private static final long serialVersionUID = 3286316764910316507L; + + /* + * Perform initializations. + */ + static { + init(); + } + + Inet4Address() { + super(); + hostName = null; + address = 0; + family = IPv4; + } + + Inet4Address(String hostName, byte addr[]) { + this.hostName = hostName; + this.family = IPv4; + if (addr != null) { + if (addr.length == INADDRSZ) { + address = addr[3] & 0xFF; + address |= ((addr[2] << 8) & 0xFF00); + address |= ((addr[1] << 16) & 0xFF0000); + address |= ((addr[0] << 24) & 0xFF000000); + } + } + } + Inet4Address(String hostName, int address) { + this.hostName = hostName; + this.family = IPv4; + this.address = address; + } + + /** + * Replaces the object to be serialized with an InetAddress object. + * + * @return the alternate object to be serialized. + * + * @throws ObjectStreamException if a new object replacing this + * object could not be created + */ + private Object writeReplace() throws ObjectStreamException { + // will replace the to be serialized 'this' object + InetAddress inet = new InetAddress(); + inet.hostName = this.hostName; + inet.address = this.address; + + /** + * Prior to 1.4 an InetAddress was created with a family + * based on the platform AF_INET value (usually 2). + * For compatibility reasons we must therefore write the + * the InetAddress with this family. + */ + inet.family = 2; + + return inet; + } + + /** + * Utility routine to check if the InetAddress is an + * IP multicast address. IP multicast address is a Class D + * address i.e first four bits of the address are 1110. + * @return a <code>boolean</code> indicating if the InetAddress is + * an IP multicast address + * @since JDK1.1 + */ + public boolean isMulticastAddress() { + return ((address & 0xf0000000) == 0xe0000000); + } + + /** + * Utility routine to check if the InetAddress in a wildcard address. + * @return a <code>boolean</code> indicating if the Inetaddress is + * a wildcard address. + * @since 1.4 + */ + public boolean isAnyLocalAddress() { + return address == 0; + } + + /** + * Utility routine to check if the InetAddress is a loopback address. + * + * @return a <code>boolean</code> indicating if the InetAddress is + * a loopback address; or false otherwise. + * @since 1.4 + */ + private static final int loopback = 2130706433; /* 127.0.0.1 */ + public boolean isLoopbackAddress() { + /* 127.x.x.x */ + byte[] byteAddr = getAddress(); + return byteAddr[0] == 127; + } + + /** + * Utility routine to check if the InetAddress is an link local address. + * + * @return a <code>boolean</code> indicating if the InetAddress is + * a link local address; or false if address is not a link local unicast address. + * @since 1.4 + */ + public boolean isLinkLocalAddress() { + // link-local unicast in IPv4 (169.254.0.0/16) + // defined in "Documenting Special Use IPv4 Address Blocks + // that have been Registered with IANA" by Bill Manning + // draft-manning-dsua-06.txt + return (((address >>> 24) & 0xFF) == 169) + && (((address >>> 16) & 0xFF) == 254); + } + + /** + * Utility routine to check if the InetAddress is a site local address. + * + * @return a <code>boolean</code> indicating if the InetAddress is + * a site local address; or false if address is not a site local unicast address. + * @since 1.4 + */ + public boolean isSiteLocalAddress() { + // refer to RFC 1918 + // 10/8 prefix + // 172.16/12 prefix + // 192.168/16 prefix + return (((address >>> 24) & 0xFF) == 10) + || ((((address >>> 24) & 0xFF) == 172) + && (((address >>> 16) & 0xF0) == 16)) + || ((((address >>> 24) & 0xFF) == 192) + && (((address >>> 16) & 0xFF) == 168)); + } + + /** + * Utility routine to check if the multicast address has global scope. + * + * @return a <code>boolean</code> indicating if the address has + * is a multicast address of global scope, false if it is not + * of global scope or it is not a multicast address + * @since 1.4 + */ + public boolean isMCGlobal() { + // 224.0.1.0 to 238.255.255.255 + byte[] byteAddr = getAddress(); + return ((byteAddr[0] & 0xff) >= 224 && (byteAddr[0] & 0xff) <= 238 ) && + !((byteAddr[0] & 0xff) == 224 && byteAddr[1] == 0 && + byteAddr[2] == 0); + } + + /** + * Utility routine to check if the multicast address has node scope. + * + * @return a <code>boolean</code> indicating if the address has + * is a multicast address of node-local scope, false if it is not + * of node-local scope or it is not a multicast address + * @since 1.4 + */ + public boolean isMCNodeLocal() { + // unless ttl == 0 + return false; + } + + /** + * Utility routine to check if the multicast address has link scope. + * + * @return a <code>boolean</code> indicating if the address has + * is a multicast address of link-local scope, false if it is not + * of link-local scope or it is not a multicast address + * @since 1.4 + */ + public boolean isMCLinkLocal() { + // 224.0.0/24 prefix and ttl == 1 + return (((address >>> 24) & 0xFF) == 224) + && (((address >>> 16) & 0xFF) == 0) + && (((address >>> 8) & 0xFF) == 0); + } + + /** + * Utility routine to check if the multicast address has site scope. + * + * @return a <code>boolean</code> indicating if the address has + * is a multicast address of site-local scope, false if it is not + * of site-local scope or it is not a multicast address + * @since 1.4 + */ + public boolean isMCSiteLocal() { + // 239.255/16 prefix or ttl < 32 + return (((address >>> 24) & 0xFF) == 239) + && (((address >>> 16) & 0xFF) == 255); + } + + /** + * Utility routine to check if the multicast address has organization scope. + * + * @return a <code>boolean</code> indicating if the address has + * is a multicast address of organization-local scope, + * false if it is not of organization-local scope + * or it is not a multicast address + * @since 1.4 + */ + public boolean isMCOrgLocal() { + // 239.192 - 239.195 + return (((address >>> 24) & 0xFF) == 239) + && (((address >>> 16) & 0xFF) >= 192) + && (((address >>> 16) & 0xFF) <= 195); + } + + /** + * Returns the raw IP address of this <code>InetAddress</code> + * object. The resul... [truncated message content] |
From: <ls...@us...> - 2009-03-19 18:13:43
|
Revision: 5119 http://jnode.svn.sourceforge.net/jnode/?rev=5119&view=rev Author: lsantha Date: 2009-03-19 18:13:36 +0000 (Thu, 19 Mar 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/src/openjdk/java/java/net/AbstractPlainSocketImpl.java Added Paths: ----------- trunk/core/src/classpath/vm/java/net/MimeTypeMapper.java trunk/core/src/openjdk/java/java/net/DatagramSocket.java trunk/core/src/openjdk/java/java/net/InterfaceAddress.java trunk/core/src/openjdk/java/java/net/MulticastSocket.java trunk/core/src/openjdk/java/java/net/NetworkInterface.java trunk/core/src/openjdk/java/java/net/ServerSocket.java trunk/core/src/openjdk/java/java/net/Socket.java trunk/core/src/openjdk/java/java/net/SocketInputStream.java trunk/core/src/openjdk/java/java/net/SocketOutputStream.java trunk/core/src/openjdk/java/java/net/SocksSocketImpl.java trunk/core/src/openjdk/svm/java/net/ trunk/core/src/openjdk/svm/java/net/DefaultDatagramSocketImplFactory.java trunk/core/src/openjdk/svm/java/net/PlainDatagramSocketImpl.java trunk/core/src/openjdk/svm/java/net/PlainSocketImpl.java trunk/core/src/openjdk/vm/java/net/NativeNetworkInterface.java trunk/core/src/openjdk/vm/java/net/NativePlainDatagramSocketImpl.java trunk/core/src/openjdk/vm/java/net/NativePlainSocketImpl.java trunk/core/src/openjdk/vm/java/net/NativeSocketInputStream.java trunk/core/src/openjdk/vm/java/net/NativeSocketOutputStream.java Removed Paths: ------------- trunk/core/src/classpath/java/java/net/DatagramSocket.java trunk/core/src/classpath/java/java/net/MimeTypeMapper.java trunk/core/src/classpath/java/java/net/MulticastSocket.java trunk/core/src/classpath/java/java/net/NetworkInterface.java trunk/core/src/classpath/java/java/net/ServerSocket.java trunk/core/src/classpath/java/java/net/Socket.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/all/conf/openjdk-annotations.properties 2009-03-19 18:13:36 UTC (rev 5119) @@ -12,6 +12,11 @@ java/lang/ThreadLocal.class=SharedStatics java/lang/Throwable.class=MagicPermission java/net/InetAddress.class=SharedStatics +# TODO DatagramSocket, ServerSocket and Socket might need to be isolated +# TODO for propperly supporting setSocketImplFactory() +java/net/DatagramSocket.class=SharedStatics +java/net/ServerSocket.class=SharedStatics +java/net/Socket.class=SharedStatics java/net/URLConnection.class=SharedStatics java/util/Currency.class=SharedStatics java/util/concurrent/locks/LockSupport.class=SharedStatics Deleted: trunk/core/src/classpath/java/java/net/DatagramSocket.java =================================================================== --- trunk/core/src/classpath/java/java/net/DatagramSocket.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/DatagramSocket.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,948 +0,0 @@ -/* DatagramSocket.java -- A class to model UDP sockets - Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005 - 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 java.net; - -import gnu.classpath.SystemProperties; - -import gnu.java.net.PlainDatagramSocketImpl; -import gnu.java.nio.DatagramChannelImpl; -import gnu.java.security.action.GetPropertyAction; - -import java.io.IOException; -import java.nio.channels.DatagramChannel; -import java.nio.channels.IllegalBlockingModeException; -import java.security.AccessController; -import org.jnode.vm.annotation.SharedStatics; - -/** - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Believed complete and correct. - */ -/** - * This class models a connectionless datagram socket that sends - * individual packets of data across the network. In the TCP/IP world, - * this means UDP. Datagram packets do not have guaranteed delivery, - * or any guarantee about the order the data will be received on the - * remote host. - * - * @author Aaron M. Renn (ar...@ur...) - * @author Warren Levy (wa...@cy...) - * @date May 3, 1999. - */ -@SharedStatics -public class DatagramSocket -{ - /** - * This is the user DatagramSocketImplFactory for this class. If this - * variable is null, a default factory is used. - */ - private static DatagramSocketImplFactory factory; - - /** - * This is the implementation object used by this socket. - */ - private DatagramSocketImpl impl; - - /** - * True if socket implementation was created. - */ - private boolean implCreated; - - /** - * This is the address we are "connected" to - */ - private InetAddress remoteAddress; - - /** - * This is the port we are "connected" to - */ - private int remotePort = -1; - - /** - * True if socket is bound. - */ - private boolean bound; - - /** - * Creates a <code>DatagramSocket</code> from a specified - * <code>DatagramSocketImpl</code> instance - * - * @param impl The <code>DatagramSocketImpl</code> the socket will be - * created from - * - * @since 1.4 - */ - protected DatagramSocket(DatagramSocketImpl impl) - { - if (impl == null) - throw new NullPointerException("impl may not be null"); - - this.impl = impl; - this.remoteAddress = null; - this.remotePort = -1; - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * a random port and every address on the local machine. - * - * @exception SocketException If an error occurs. - * @exception SecurityException If a security manager exists and - * its <code>checkListen</code> method doesn't allow the operation. - */ - public DatagramSocket() throws SocketException - { - this(new InetSocketAddress(0)); - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * the specified port and every address on the local machine. - * - * @param port The local port number to bind to. - * - * @exception SecurityException If a security manager exists and its - * <code>checkListen</code> method doesn't allow the operation. - * @exception SocketException If an error occurs. - */ - public DatagramSocket(int port) throws SocketException - { - this(new InetSocketAddress(port)); - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * the specified local port and address. - * - * @param port The local port number to bind to. - * @param addr The local address to bind to. - * - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation. - * @exception SocketException If an error occurs. - */ - public DatagramSocket(int port, InetAddress addr) throws SocketException - { - this(new InetSocketAddress(addr, port)); - } - - /** - * Initializes a new instance of <code>DatagramSocket</code> that binds to - * the specified local port and address. - * - * @param address The local address and port number to bind to. - * - * @exception SecurityException If a security manager exists and its - * <code>checkListen</code> method doesn't allow the operation. - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public DatagramSocket(SocketAddress address) throws SocketException - { - // @classpath-bugfix Security - //String propVal = SystemProperties.getProperty("impl.prefix"); - //if (propVal == null || propVal.equals("")) - String propVal = (String)AccessController.doPrivileged(new GetPropertyAction("impl.prefix")); - // @classpath-bugfix-end - - // @classpath-bugfix Use factory - //if (propVal == null || propVal.equals("")) - if (factory != null) { - impl = factory.createDatagramSocketImpl(); - } else if (propVal == null || propVal.equals("")) - // @classpath-bugfix-end - impl = new PlainDatagramSocketImpl(); - else - try - { - impl = - (DatagramSocketImpl) Class.forName("java.net." + propVal - + "DatagramSocketImpl") - .newInstance(); - } - catch (Exception e) - { - System.err.println("Could not instantiate class: java.net." - + propVal + "DatagramSocketImpl"); - impl = new PlainDatagramSocketImpl(); - } - - if (address != null) - bind(address); - } - - // This needs to be accessible from java.net.MulticastSocket - DatagramSocketImpl getImpl() throws SocketException - { - try - { - if (! implCreated) - { - impl.create(); - implCreated = true; - } - - return impl; - } - catch (IOException e) - { - SocketException se = new SocketException(); - se.initCause(e); - throw se; - } - } - - /** - * Closes this datagram socket. - */ - public void close() - { - if (isClosed()) - return; - - try - { - getImpl().close(); - } - catch (SocketException e) - { - // Ignore this case, just close the socket in finally clause. - } - finally - { - remoteAddress = null; - remotePort = -1; - impl = null; - } - - try - { - if (getChannel() != null) - getChannel().close(); - } - catch (IOException e) - { - // Do nothing. - } - } - - /** - * This method returns the remote address to which this socket is - * connected. If this socket is not connected, then this method will - * return <code>null</code>. - * - * @return The remote address. - * - * @since 1.2 - */ - public InetAddress getInetAddress() - { - return remoteAddress; - } - - /** - * This method returns the remote port to which this socket is - * connected. If this socket is not connected, then this method will - * return -1. - * - * @return The remote port. - * - * @since 1.2 - */ - public int getPort() - { - return remotePort; - } - - /** - * Returns the local address this datagram socket is bound to. - * - * @return The local address is the socket is bound or null - * - * @since 1.1 - */ - public InetAddress getLocalAddress() - { - if (! isBound()) - return null; - - InetAddress localAddr; - - try - { - localAddr = - (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkConnect(localAddr.getHostName(), -1); - } - catch (SecurityException e) - { - localAddr = NativeInetAddress.ANY_IF; - } - catch (SocketException e) - { - // This cannot happen as we are bound. - return null; - } - - return localAddr; - } - - /** - * Returns the local port this socket is bound to. - * - * @return The local port number. - */ - public int getLocalPort() - { - if (isClosed()) - return -1; - - try - { - return getImpl().getLocalPort(); - } - catch (SocketException e) - { - // This cannot happen as we are bound. - return 0; - } - } - - /** - * Returns the value of the socket's SO_TIMEOUT setting. If this method - * returns 0 then SO_TIMEOUT is disabled. - * - * @return The current timeout in milliseconds. - * - * @exception SocketException If an error occurs. - * - * @since 1.1 - */ - public synchronized int getSoTimeout() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_TIMEOUT); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the value of the socket's SO_TIMEOUT value. A value of 0 will - * disable SO_TIMEOUT. Any other value is the number of milliseconds - * a socket read/write will block before timing out. - * - * @param timeout The new SO_TIMEOUT value in milliseconds. - * - * @exception SocketException If an error occurs. - * - * @since 1.1 - */ - public synchronized void setSoTimeout(int timeout) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (timeout < 0) - throw new IllegalArgumentException("Invalid timeout: " + timeout); - - getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout)); - } - - /** - * This method returns the value of the system level socket option - * SO_SNDBUF, which is used by the operating system to tune buffer - * sizes for data transfers. - * - * @return The send buffer size. - * - * @exception SocketException If an error occurs. - * - * @since 1.2 - */ - public int getSendBufferSize() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * This method sets the value for the system level socket option - * SO_SNDBUF to the specified value. Note that valid values for this - * option are specific to a given operating system. - * - * @param size The new send buffer size. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If size is 0 or negative. - * - * @since 1.2 - */ - public void setSendBufferSize(int size) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (size < 0) - throw new IllegalArgumentException("Buffer size is less than 0"); - - getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size)); - } - - /** - * This method returns the value of the system level socket option - * SO_RCVBUF, which is used by the operating system to tune buffer - * sizes for data transfers. - * - * @return The receive buffer size. - * - * @exception SocketException If an error occurs. - * - * @since 1.2 - */ - public int getReceiveBufferSize() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * This method sets the value for the system level socket option - * SO_RCVBUF to the specified value. Note that valid values for this - * option are specific to a given operating system. - * - * @param size The new receive buffer size. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If size is 0 or negative. - * - * @since 1.2 - */ - public void setReceiveBufferSize(int size) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (size < 0) - throw new IllegalArgumentException("Buffer size is less than 0"); - - getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size)); - } - - /** - * This method connects this socket to the specified address and port. - * When a datagram socket is connected, it will only send or receive - * packets to and from the host to which it is connected. A multicast - * socket that is connected may only send and not receive packets. - * - * @param address The address to connect this socket to. - * @param port The port to connect this socket to. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If address or port are invalid. - * @exception SecurityException If the caller is not allowed to send - * datagrams to or receive from this address and port. - * - * @since 1.2 - */ - public void connect(InetAddress address, int port) - { - if (address == null) - throw new IllegalArgumentException("Connect address may not be null"); - - if ((port < 1) || (port > 65535)) - throw new IllegalArgumentException("Port number is illegal: " + port); - - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkConnect(address.getHostName(), port); - - try - { - getImpl().connect(address, port); - remoteAddress = address; - remotePort = port; - } - catch (SocketException e) - { - // This means simply not connected or connect not implemented. - } - } - - /** - * This method disconnects this socket from the address/port it was - * connected to. If the socket was not connected in the first place, - * this method does nothing. - * - * @since 1.2 - */ - public void disconnect() - { - if (! isConnected()) - return; - - try - { - getImpl().disconnect(); - } - catch (SocketException e) - { - // This cannot happen as we are connected. - } - finally - { - remoteAddress = null; - remotePort = -1; - } - } - - /** - * Reads a datagram packet from the socket. Note that this method - * will block until a packet is received from the network. On return, - * the passed in <code>DatagramPacket</code> is populated with the data - * received and all the other information about the packet. - * - * @param p A <code>DatagramPacket</code> for storing the data - * - * @exception IOException If an error occurs. - * @exception SocketTimeoutException If setSoTimeout was previously called - * and the timeout has expired. - * @exception PortUnreachableException If the socket is connected to a - * currently unreachable destination. Note, there is no guarantee that the - * exception will be thrown. - * @exception IllegalBlockingModeException If this socket has an associated - * channel, and the channel is in non-blocking mode. - * @exception SecurityException If a security manager exists and its - * checkAccept method doesn't allow the receive. - */ - public synchronized void receive(DatagramPacket p) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (remoteAddress != null && remoteAddress.isMulticastAddress()) - throw new IOException - ("Socket connected to a multicast address my not receive"); - - if (getChannel() != null && ! getChannel().isBlocking() - && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation()) - throw new IllegalBlockingModeException(); - - getImpl().receive(p); - - SecurityManager s = System.getSecurityManager(); - if (s != null && isConnected()) - s.checkAccept(p.getAddress().getHostName(), p.getPort()); - } - - /** - * Sends the specified packet. The host and port to which the packet - * are to be sent should be set inside the packet. - * - * @param p The datagram packet to send. - * - * @exception IOException If an error occurs. - * @exception SecurityException If a security manager exists and its - * checkMulticast or checkConnect method doesn't allow the send. - * @exception PortUnreachableException If the socket is connected to a - * currently unreachable destination. Note, there is no guarantee that the - * exception will be thrown. - * @exception IllegalBlockingModeException If this socket has an associated - * channel, and the channel is in non-blocking mode. - */ - public void send(DatagramPacket p) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api. - SecurityManager s = System.getSecurityManager(); - if (s != null && ! isConnected()) - { - InetAddress addr = p.getAddress(); - if (addr.isMulticastAddress()) - s.checkMulticast(addr); - else - s.checkConnect(addr.getHostAddress(), p.getPort()); - } - - if (isConnected()) - { - if (p.getAddress() != null - && (remoteAddress != p.getAddress() || remotePort != p.getPort())) - throw new IllegalArgumentException - ("DatagramPacket address does not match remote address"); - } - - // FIXME: if this is a subclass of MulticastSocket, - // use getTimeToLive for TTL val. - if (getChannel() != null && ! getChannel().isBlocking() - && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation()) - throw new IllegalBlockingModeException(); - - getImpl().send(p); - } - - /** - * Binds the socket to the given socket address. - * - * @param address The socket address to bind to. - * - * @exception SocketException If an error occurs. - * @exception SecurityException If a security manager exists and - * its checkListen method doesn't allow the operation. - * @exception IllegalArgumentException If address type is not supported. - * - * @since 1.4 - */ - public void bind(SocketAddress address) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! (address instanceof InetSocketAddress)) - throw new IllegalArgumentException("unsupported address type"); - - InetAddress addr = ((InetSocketAddress) address).getAddress(); - int port = ((InetSocketAddress) address).getPort(); - - if (port < 0 || port > 65535) - throw new IllegalArgumentException("Invalid port: " + port); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkListen(port); - - if (addr == null) - addr = NativeInetAddress.ANY_IF; - - try - { - getImpl().bind(port, addr); - bound = true; - } - catch (SocketException exception) - { - getImpl().close(); - throw exception; - } - catch (RuntimeException exception) - { - getImpl().close(); - throw exception; - } - catch (Error error) - { - getImpl().close(); - throw error; - } - } - - /** - * Checks if the datagram socket is closed. - * - * @return True if socket is closed, false otherwise. - * - * @since 1.4 - */ - public boolean isClosed() - { - return impl == null; - } - - /** - * Returns the datagram channel assoziated with this datagram socket. - * - * @return The associated <code>DatagramChannel</code> object or null - * - * @since 1.4 - */ - public DatagramChannel getChannel() - { - return null; - } - - /** - * Connects the datagram socket to a specified socket address. - * - * @param address The socket address to connect to. - * - * @exception SocketException If an error occurs. - * @exception IllegalArgumentException If address type is not supported. - * - * @since 1.4 - */ - public void connect(SocketAddress address) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! (address instanceof InetSocketAddress)) - throw new IllegalArgumentException("unsupported address type"); - - InetSocketAddress tmp = (InetSocketAddress) address; - connect(tmp.getAddress(), tmp.getPort()); - } - - /** - * Returns the binding state of the socket. - * - * @return True if socket bound, false otherwise. - * - * @since 1.4 - */ - public boolean isBound() - { - return bound; - } - - /** - * Returns the connection state of the socket. - * - * @return True if socket is connected, false otherwise. - * - * @since 1.4 - */ - public boolean isConnected() - { - return remoteAddress != null; - } - - /** - * Returns the SocketAddress of the host this socket is conneted to - * or null if this socket is not connected. - * - * @return The socket address of the remote host if connected or null - * - * @since 1.4 - */ - public SocketAddress getRemoteSocketAddress() - { - if (! isConnected()) - return null; - - return new InetSocketAddress(remoteAddress, remotePort); - } - - /** - * Returns the local SocketAddress this socket is bound to. - * - * @return The local SocketAddress or null if the socket is not bound. - * - * @since 1.4 - */ - public SocketAddress getLocalSocketAddress() - { - if (! isBound()) - return null; - - return new InetSocketAddress(getLocalAddress(), getLocalPort()); - } - - /** - * Enables/Disables SO_REUSEADDR. - * - * @param on Whether or not to have SO_REUSEADDR turned on. - * - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public void setReuseAddress(boolean on) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on)); - } - - /** - * Checks if SO_REUSEADDR is enabled. - * - * @return True if SO_REUSEADDR is set on the socket, false otherwise. - * - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public boolean getReuseAddress() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_REUSEADDR); - - if (buf instanceof Boolean) - return ((Boolean) buf).booleanValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Enables/Disables SO_BROADCAST - * - * @param enable True if SO_BROADCAST should be enabled, false otherwise. - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public void setBroadcast(boolean enable) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.SO_BROADCAST, Boolean.valueOf(enable)); - } - - /** - * Checks if SO_BROADCAST is enabled - * - * @return Whether SO_BROADCAST is set - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public boolean getBroadcast() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.SO_BROADCAST); - - if (buf instanceof Boolean) - return ((Boolean) buf).booleanValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the traffic class value - * - * @param tc The traffic class - * - * @exception SocketException If an error occurs - * @exception IllegalArgumentException If tc value is illegal - * - * @see DatagramSocket#getTrafficClass() - * - * @since 1.4 - */ - public void setTrafficClass(int tc) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (tc < 0 || tc > 255) - throw new IllegalArgumentException(); - - getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc)); - } - - /** - * Returns the current traffic class - * - * @return The current traffic class. - * - * @see DatagramSocket#setTrafficClass(int tc) - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public int getTrafficClass() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.IP_TOS); - - if (buf instanceof Integer) - return ((Integer) buf).intValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the datagram socket implementation factory for the application - * - * @param fac The factory to set - * - * @exception IOException If an error occurs - * @exception SocketException If the factory is already defined - * @exception SecurityException If a security manager exists and its - * checkSetFactory method doesn't allow the operation - */ - public static void setDatagramSocketImplFactory(DatagramSocketImplFactory fac) - throws IOException - { - if (factory != null) - throw new SocketException("DatagramSocketImplFactory already defined"); - - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkSetFactory(); - - factory = fac; - } -} Deleted: trunk/core/src/classpath/java/java/net/MimeTypeMapper.java =================================================================== --- trunk/core/src/classpath/java/java/net/MimeTypeMapper.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/MimeTypeMapper.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,346 +0,0 @@ -/* MimeTypeMapper.java -- A class for mapping file names to MIME types - Copyright (C) 1998 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 java.net; - -import gnu.classpath.SystemProperties; - -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.StringTokenizer; -import java.util.TreeMap; - - -/** - * This non-public class is used to implement the FileNameMap interface - * which defines a mechanism for mapping filenames to MIME types. - * - * @version 0.5 - * - * @author Aaron M. Renn (ar...@ur...) - */ -class MimeTypeMapper implements FileNameMap -{ - /** - * This array of strings is used to identify a MIME type based on a file - * extension. This is list is based on the Apache mime.types file. - */ - protected static final String[][] mime_strings = - { - { "ai", "application/postscript" } - , { "aif", "audio/x-aiff" } - , { "aifc", "audio/x-aiff" } - , { "aiff", "audio/x-aiff" } - , { "asc", "text/plain" } - , { "au", "audio/basic" } - , { "avi", "video/x-msvideo" } - , { "bcpio", "application/x-bcpio" } - , { "bin", "application/octet-stream" } - , { "bmp", "image/bmp" } - , { "bz2", "application/x-bzip2" } - , { "cdf", "application/x-netcdf" } - , { "chrt", "application/x-kchart" } - , { "class", "application/octet-stream" } - , { "cpio", "application/x-cpio" } - , { "cpt", "application/mac-compactpro" } - , { "csh", "application/x-csh" } - , { "css", "text/css" } - , { "dcr", "application/x-director" } - , { "dir", "application/x-director" } - , { "djv", "image/vnd.djvu" } - , { "djvu", "image/vnd.djvu" } - , { "dll", "application/octet-stream" } - , { "dms", "application/octet-stream" } - , { "doc", "application/msword" } - , { "dvi", "application/x-dvi" } - , { "dxr", "application/x-director" } - , { "eps", "application/postscript" } - , { "etx", "text/x-setext" } - , { "exe", "application/octet-stream" } - , { "ez", "application/andrew-inset" } - , { "gif", "image/gif" } - , { "gtar", "application/x-gtar" } - , { "gz", "application/x-gzip" } - , { "hdf", "application/x-hdf" } - , { "hqx", "application/mac-binhex40" } - , { "htm", "text/html" } - , { "html", "text/html" } - , { "ice", "x-conference/x-cooltalk" } - , { "ief", "image/ief" } - , { "iges", "model/iges" } - , { "igs", "model/iges" } - , { "img", "application/octet-stream" } - , { "iso", "application/octet-stream" } - , { "jpe", "image/jpeg" } - , { "jpeg", "image/jpeg" } - , { "jpg", "image/jpeg" } - , { "js", "application/x-javascript" } - , { "kar", "audio/midi" } - , { "kil", "application/x-killustrator" } - , { "kpr", "application/x-kpresenter" } - , { "kpt", "application/x-kpresenter" } - , { "ksp", "application/x-kspread" } - , { "kwd", "application/x-kword" } - , { "kwt", "application/x-kword" } - , { "latex", "application/x-latex" } - , { "lha", "application/octet-stream" } - , { "lzh", "application/octet-stream" } - , { "m3u", "audio/x-mpegurl" } - , { "man", "application/x-troff-man" } - , { "me", "application/x-troff-me" } - , { "mesh", "model/mesh" } - , { "mid", "audio/midi" } - , { "midi", "audio/midi" } - , { "mif", "application/vnd.mif" } - , { "mov", "video/quicktime" } - , { "movie", "video/x-sgi-movie" } - , { "mp2", "audio/mpeg" } - , { "mp3", "audio/mpeg" } - , { "mpe", "video/mpeg" } - , { "mpeg", "video/mpeg" } - , { "mpg", "video/mpeg" } - , { "mpga", "audio/mpeg" } - , { "ms", "application/x-troff-ms" } - , { "msh", "model/mesh" } - , { "mxu", "video/vnd.mpegurl" } - , { "nc", "application/x-netcdf" } - , { "ogg", "application/ogg" } - , { "pbm", "image/x-portable-bitmap" } - , { "pdb", "chemical/x-pdb" } - , { "pdf", "application/pdf" } - , { "pgm", "image/x-portable-graymap" } - , { "pgn", "application/x-chess-pgn" } - , { "png", "image/png" } - , { "pnm", "image/x-portable-anymap" } - , { "ppm", "image/x-portable-pixmap" } - , { "ppt", "application/vnd.ms-powerpoint" } - , { "ps", "application/postscript" } - , { "qt", "video/quicktime" } - , { "ra", "audio/x-realaudio" } - , { "ram", "audio/x-pn-realaudio" } - , { "ras", "image/x-cmu-raster" } - , { "rgb", "image/x-rgb" } - , { "rm", "audio/x-pn-realaudio" } - , { "roff", "application/x-troff" } - , { "rpm", "application/x-rpm" } - , { "rtf", "text/rtf" } - , { "rtx", "text/richtext" } - , { "sgm", "text/sgml" } - , { "sgml", "text/sgml" } - , { "sh", "application/x-sh" } - , { "shar", "application/x-shar" } - , { "silo", "model/mesh" } - , { "sit", "application/x-stuffit" } - , { "skd", "application/x-koan" } - , { "skm", "application/x-koan" } - , { "skp", "application/x-koan" } - , { "skt", "application/x-koan" } - , { "smi", "application/smil" } - , { "smil", "application/smil" } - , { "snd", "audio/basic" } - , { "so", "application/octet-stream" } - , { "spl", "application/x-futuresplash" } - , { "src", "application/x-wais-source" } - , { "stc", "application/vnd.sun.xml.calc.template" } - , { "std", "application/vnd.sun.xml.draw.template" } - , { "sti", "application/vnd.sun.xml.impress.template" } - , { "stw", "application/vnd.sun.xml.writer.template" } - , { "sv4cpio", "application/x-sv4cpio" } - , { "sv4crc", "application/x-sv4crc" } - , { "swf", "application/x-shockwave-flash" } - , { "sxc", "application/vnd.sun.xml.calc" } - , { "sxd", "application/vnd.sun.xml.draw" } - , { "sxg", "application/vnd.sun.xml.writer.global" } - , { "sxi", "application/vnd.sun.xml.impress" } - , { "sxm", "application/vnd.sun.xml.math" } - , { "sxw", "application/vnd.sun.xml.writer" } - , { "t", "application/x-troff" } - , { "tar", "application/x-tar" } - , { "tcl", "application/x-tcl" } - , { "tex", "application/x-tex" } - , { "texi", "application/x-texinfo" } - , { "texinfo", "application/x-texinfo" } - , { "tgz", "application/x-gzip" } - , { "tif", "image/tiff" } - , { "tiff", "image/tiff" } - , { "torrent", "application/x-bittorrent" } - , { "tr", "application/x-troff" } - , { "tsv", "text/tab-separated-values" } - , { "txt", "text/plain" } - , { "ustar", "application/x-ustar" } - , { "vcd", "application/x-cdlink" } - , { "vrml", "model/vrml" } - , { "wav", "audio/x-wav" } - , { "wbmp", "image/vnd.wap.wbmp" } - , { "wbxml", "application/vnd.wap.wbxml" } - , { "wml", "text/vnd.wap.wml" } - , { "wmlc", "application/vnd.wap.wmlc" } - , { "wmls", "text/vnd.wap.wmlscript" } - , { "wmlsc", "application/vnd.wap.wmlscriptc" } - , { "wrl", "model/vrml" } - , { "xbm", "image/x-xbitmap" } - , { "xht", "application/xhtml+xml" } - , { "xhtml", "application/xhtml+xml" } - , { "xls", "application/vnd.ms-excel" } - , { "xml", "text/xml" } - , { "xpm", "image/x-xpixmap" } - , { "xsl", "text/xml" } - , { "xwd", "image/x-xwindowdump" } - , { "xyz", "chemical/x-xyz" } - , { "zip", "application/zip" } - }; - - /** - * The MIME types above are put into this Hashtable for faster lookup. - */ - private Hashtable<String, String> mime_types - = new Hashtable<String, String>(150); - - /** - * Create a new <code>MimeTypeMapper</code> object. - */ - public MimeTypeMapper() - { - for (int i = 0; i < mime_strings.length; i++) - mime_types.put(mime_strings[i][0], mime_strings[i][1]); - - // Now read from the system mime database, if it exists. Entries found - // here override our internal ones. - try - { - // On Linux this usually means /etc/mime.types. - String file - = SystemProperties.getProperty("gnu.classpath.mime.types.file"); - if (file != null) - fillFromFile(mime_types, file); - } - catch (IOException ignore) - { - } - } - - public static void fillFromFile (Map<String, String> table, String fname) - throws IOException - { - LineNumberReader reader = - new LineNumberReader (new FileReader (fname)); - - while (reader.ready ()) - { - StringTokenizer tokenizer = - new StringTokenizer (reader.readLine ()); - - try - { - String t = tokenizer.nextToken (); - - if (! t.startsWith ("#")) - { - while (true) - { - // Read the next extension - String e = tokenizer.nextToken (); - if ((e != null) && (! e.startsWith ("#"))) - table.put (e, t); - else - break; - } - } - } - catch (NoSuchElementException ex) - { - // Do nothing. - } - } - } - - /** - * The method returns the MIME type of the filename passed as an argument. - * The value returned is based on the extension of the filename. The - * default content type returned if this method cannot determine the - * actual content type is "application/octet-stream" - * - * @param filename The name of the file to return the MIME type for - * - * @return The MIME type - */ - public String getContentTypeFor(String filename) - { - int index = filename.lastIndexOf("."); - if (index != -1) - { - if (index == filename.length()) - return "application/octet-stream"; - else - filename = filename.substring(index + 1); - } - - String type = (String) mime_types.get(filename); - if (type == null) - return "application/octet-stream"; - else - return type; - } - - /** - * Run this class as a program to create a new mime_strings table. - */ - public static void main(String[] args) throws IOException - { - TreeMap<String, String> map = new TreeMap<String, String>(); - // It is fine to hard-code the name here. This is only ever - // used by maintainers, who can hack it if they need to re-run - // it. - fillFromFile(map, "/etc/mime.types"); - Iterator<String> it = map.keySet().iterator(); - boolean first = true; - while (it.hasNext()) - { - String key = it.next(); - String value = map.get(key); - // Put the "," first since it is easier to make correct syntax this way. - System.out.println(" " + (first ? " " : ", ") - + "{ \"" + key + "\", \"" + value + "\" }"); - first = false; - } - } -} Deleted: trunk/core/src/classpath/java/java/net/MulticastSocket.java =================================================================== --- trunk/core/src/classpath/java/java/net/MulticastSocket.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/MulticastSocket.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,490 +0,0 @@ -/* MulticastSocket.java -- Class for using multicast sockets - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 - 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 java.net; - -import java.io.IOException; -import java.util.Enumeration; - - -/** - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Believed complete and correct. - */ -/** - * This class models a multicast UDP socket. A multicast address is a - * class D internet address (one whose most significant bits are 1110). - * A multicast group consists of a multicast address and a well known - * port number. All members of the group listening on that address and - * port will receive all the broadcasts to the group. - * <p> - * Please note that applets are not allowed to use multicast sockets - * - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Believed complete and correct. - * - * @author Warren Levy (wa...@cy...) - * @author Aaron M. Renn (ar...@ur...) (Documentation comments) - * @since 1.1 - * @date May 18, 1999. - */ -public class MulticastSocket extends DatagramSocket -{ - /** - * Create a MulticastSocket that this not bound to any address - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation - */ - public MulticastSocket() throws IOException - { - this(new InetSocketAddress(0)); - } - - /** - * Create a multicast socket bound to the specified port - * - * @param port The port to bind to - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation - */ - public MulticastSocket(int port) throws IOException - { - this(new InetSocketAddress(port)); - } - - /** - * Create a multicast socket bound to the specified SocketAddress. - * - * @param address The SocketAddress the multicast socket will be bound to - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkListen method doesn't allow the operation - * - * @since 1.4 - */ - public MulticastSocket(SocketAddress address) throws IOException - { - super((SocketAddress) null); - setReuseAddress(true); - if (address != null) - bind(address); - } - - /** - * Returns the interface being used for multicast packets - * - * @return The multicast interface - * - * @exception SocketException If an error occurs - */ - public InetAddress getInterface() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); - } - - /** - * Returns the current value of the "Time to Live" option. This is the - * number of hops a packet can make before it "expires". This method id - * deprecated. Use <code>getTimeToLive</code> instead. - * - * @return The TTL value - * - * @exception IOException If an error occurs - * - * @deprecated 1.2 Replaced by getTimeToLive() - * - * @see MulticastSocket#getTimeToLive() - */ - public byte getTTL() throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // Use getTTL here rather than getTimeToLive in case we're using an impl - // other than the default PlainDatagramSocketImpl and it doesn't have - // getTimeToLive yet. - return getImpl().getTTL(); - } - - /** - * Returns the current value of the "Time to Live" option. This is the - * number of hops a packet can make before it "expires". - * - * @return The TTL value - * - * @exception IOException If an error occurs - * - * @since 1.2 - */ - public int getTimeToLive() throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - return getImpl().getTimeToLive(); - } - - /** - * Sets the interface to use for sending multicast packets. - * - * @param addr The new interface to use. - * - * @exception SocketException If an error occurs. - * - * @since 1.4 - */ - public void setInterface(InetAddress addr) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr); - } - - /** - * Sets the local network interface used to send multicast messages - * - * @param netIf The local network interface used to send multicast messages - * - * @exception SocketException If an error occurs - * - * @see MulticastSocket#getNetworkInterface() - * - * @since 1.4 - */ - public void setNetworkInterface(NetworkInterface netIf) - throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // @vm-specific Set network interface via extended option - getImpl().setOption(ExSocketOptions.SO_TRANSMIT_IF, netIf); -/* - Enumeration e = netIf.getInetAddresses(); - - if (! e.hasMoreElements()) - throw new SocketException("no network devices found"); - - InetAddress address = (InetAddress) e.nextElement(); - getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address); -*/ - } - - /** - * Gets the local network interface which is used to send multicast messages - * - * @return The local network interface to send multicast messages - * - * @exception SocketException If an error occurs - * - * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) - * - * @since 1.4 - */ - public NetworkInterface getNetworkInterface() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - InetAddress address = - (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); - NetworkInterface netIf = NetworkInterface.getByInetAddress(address); - - return netIf; - } - - /** - * Disable/Enable local loopback of multicast packets. The option is used by - * the platform's networking code as a hint for setting whether multicast - * data will be looped back to the local socket. - * - * Because this option is a hint, applications that want to verify what - * loopback mode is set to should call #getLoopbackMode - * - * @param disable True to disable loopback mode - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public void setLoopbackMode(boolean disable) throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP, - Boolean.valueOf(disable)); - } - - /** - * Checks if local loopback mode is enabled - * - * @return true if loopback mode is enabled, false otherwise - * - * @exception SocketException If an error occurs - * - * @since 1.4 - */ - public boolean getLoopbackMode() throws SocketException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - Object buf = getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP); - - if (buf instanceof Boolean) - return ((Boolean) buf).booleanValue(); - - throw new SocketException("unexpected type"); - } - - /** - * Sets the "Time to Live" value for a socket. The value must be between - * 1 and 255. - * - * @param ttl The new TTL value - * - * @exception IOException If an error occurs - * - * @deprecated 1.2 Replaced by <code>setTimeToLive</code> - * - * @see MulticastSocket#setTimeToLive(int ttl) - */ - public void setTTL(byte ttl) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - // Use setTTL here rather than setTimeToLive in case we're using an impl - // other than the default PlainDatagramSocketImpl and it doesn't have - // setTimeToLive yet. - getImpl().setTTL(ttl); - } - - /** - * Sets the "Time to Live" value for a socket. The value must be between - * 1 and 255. - * - * @param ttl The new TTL value - * - * @exception IOException If an error occurs - * - * @since 1.2 - */ - public void setTimeToLive(int ttl) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (ttl <= 0 || ttl > 255) - throw new IllegalArgumentException("Invalid ttl: " + ttl); - - getImpl().setTimeToLive(ttl); - } - - /** - * Joins the specified multicast group. - * - * @param mcastaddr The address of the group to join - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - */ - public void joinGroup(InetAddress mcastaddr) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! mcastaddr.isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(mcastaddr); - - getImpl().join(mcastaddr); - } - - /** - * Leaves the specified multicast group - * - * @param mcastaddr The address of the group to leave - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - */ - public void leaveGroup(InetAddress mcastaddr) throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! mcastaddr.isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(mcastaddr); - - getImpl().leave(mcastaddr); - } - - /** - * Joins the specified mulitcast group on a specified interface. - * - * @param mcastaddr The multicast address to join - * @param netIf The local network interface to receive the multicast - * messages on or null to defer the interface set by #setInterface or - * #setNetworkInterface - * - * @exception IOException If an error occurs - * @exception IllegalArgumentException If address type is not supported - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - * - * @see MulticastSocket#setInterface(InetAddress addr) - * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) - * - * @since 1.4 - */ - public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - if (! (mcastaddr instanceof InetSocketAddress)) - throw new IllegalArgumentException("SocketAddress type not supported"); - - InetSocketAddress tmp = (InetSocketAddress) mcastaddr; - - if (! tmp.getAddress().isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(tmp.getAddress()); - - getImpl().joinGroup(mcastaddr, netIf); - } - - /** - * Leaves the specified mulitcast group on a specified interface. - * - * @param mcastaddr The multicast address to leave - * @param netIf The local networki interface or null to defer to the - * interface set by setInterface or setNetworkInterface - * - * @exception IOException If an error occurs - * @exception IllegalArgumentException If address type is not supported - * @exception SecurityException If a security manager exists and its - * checkMulticast method doesn't allow the operation - * - * @see MulticastSocket#setInterface(InetAddress addr) - * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) - * - * @since 1.4 - */ - public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - InetSocketAddress tmp = (InetSocketAddress) mcastaddr; - - if (! tmp.getAddress().isMulticastAddress()) - throw new IOException("Not a Multicast address"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkMulticast(tmp.getAddress()); - - getImpl().leaveGroup(mcastaddr, netIf); - } - - /** - * Sends a packet of data to a multicast address with a TTL that is - * different from the default TTL on this socket. The default TTL for - * the socket is not changed. - * - * @param packet The packet of data to send - * @param ttl The TTL for this packet - * - * @exception IOException If an error occurs - * @exception SecurityException If a security manager exists and its - * checkConnect or checkMulticast method doesn't allow the operation - * - * @deprecated - */ - public synchronized void send(DatagramPacket packet, byte ttl) - throws IOException - { - if (isClosed()) - throw new SocketException("socket is closed"); - - SecurityManager s = System.getSecurityManager(); - if (s != null) - { - InetAddress addr = packet.getAddress(); - if (addr.isMulticastAddress()) - s.checkPermission(new SocketPermission(addr.getHostName() - + packet.getPort(), - "accept,connect")); - else - s.checkConnect(addr.getHostAddress(), packet.getPort()); - } - - int oldttl = getImpl().getTimeToLive(); - getImpl().setTimeToLive(((int) ttl) & 0xFF); - getImpl().send(packet); - getImpl().setTimeToLive(oldttl); - } -} Deleted: trunk/core/src/classpath/java/java/net/NetworkInterface.java =================================================================== --- trunk/core/src/classpath/java/java/net/NetworkInterface.java 2009-03-19 16:23:45 UTC (rev 5118) +++ trunk/core/src/classpath/java/java/net/NetworkInterface.java 2009-03-19 18:13:36 UTC (rev 5119) @@ -1,191 +0,0 @@ -/* NetworkInterface.java - Copyright (C) 2002 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., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 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 java.net; - -import java.util.Enumeration; -import java.util.Iterator; -impor... [truncated message content] |