Skip to content
Browse files

JRUBY-994: Remove jruby serialization feature

git-svn-id: https://svn.codehaus.org/jruby/trunk/jruby@3734 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 6326664 commit 44da7d71e63482fd1f9b6b1ef32caa4a3b516172 enebo committed
View
3 .classpath
@@ -4,11 +4,10 @@
<classpathentry excluding="**/CVS/*" kind="src" output="build/classes/test" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/bsf.jar"/>
- <classpathentry kind="lib" path="lib/junit.jar"/>
- <classpathentry kind="lib" path="lib/ant.jar"/>
<classpathentry kind="lib" path="lib/asm-commons-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/asm-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jline-0.9.91.jar"/>
<classpathentry kind="lib" path="lib/backport-util-concurrent.jar"/>
+ <classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="output" path="build/classes/jruby"/>
</classpath>
View
12 .externalToolBuilders/Serialize Builtin Files.launch
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
-<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot; editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/jruby/src/compiler&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/jruby/src/builtin&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;&#10;}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc}/build.xml"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_TARGETS" value="serialize,"/>
-</launchConfiguration>
View
12 .project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jruby</name>
+ <name>jruby_trunk</name>
<comment></comment>
<projects>
</projects>
@@ -12,16 +12,6 @@
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
- <triggers>auto,full,incremental,</triggers>
- <arguments>
- <dictionary>
- <key>LaunchConfigHandle</key>
- <value>&lt;project&gt;/.externalToolBuilders/Serialize Builtin Files.launch</value>
- </dictionary>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
View
28 build.xml
@@ -97,14 +97,9 @@
<classpath refid="build.classpath"/>
</javac>
- <taskdef name="jruby-serialize" classname="org.jruby.util.ant.JRubySerialize">
- <classpath path="${jruby.classes.dir}"/>
- </taskdef>
-
<copy todir="${jruby.classes.dir}">
<fileset dir="${src.dir}">
<include name="**/*.rb"/>
- <exclude name="builtin/**/*.rb"/>
</fileset>
</copy>
@@ -137,16 +132,7 @@
description="Compile the source files for the project.">
</target>
- <target name="serialize" depends="compile"
- description="Serializes builting Ruby libraries into Java format">
- <jruby-serialize destdir="${jruby.classes.dir}">
- <fileset dir="${src.dir}">
- <include name="builtin/**/*.rb"/>
- </fileset>
- </jruby-serialize>
- </target>
-
- <target name="generate-method-classes" depends="serialize">
+ <target name="generate-method-classes" depends="compile">
<touch file="${build.dir}/__empty.rb"/>
<java classname="org.jruby.Main" fork="true">
<classpath refid="build.classpath"/>
@@ -158,15 +144,6 @@
<delete file="${build.dir}/__empty.rb" quiet="true"/>
</target>
- <target name="serialize.rubylib" depends="compile"
- description="Serializes the core Ruby library into Java format">
- <jruby-serialize destdir="${jruby.classes.dir}" verbose="true">
- <fileset dir="${ruby.home}/lib/ruby/1.8">
- <patternset refid="ruby.src.pattern"/>
- </fileset>
- </jruby-serialize>
- </target>
-
<target name="jar-jruby" depends="generate-method-classes">
<jar destfile="${lib.dir}/jruby.jar" compress="true">
<fileset dir="${jruby.classes.dir}">
@@ -220,7 +197,6 @@
<fileset dir="${jruby.classes.dir}">
<include name="**/*.class"/>
<include name="**/*.properties"/>
- <include name="**/*.rb.ast.ser"/>
<exclude name="org/jruby/util/ant/**/*.class"/>
</fileset>
<fileset dir="${basedir}/lib/ruby/1.8">
@@ -264,7 +240,7 @@
<target name="jar" depends="jar-jruby" description="Create the jruby.jar file">
</target>
- <target name="jar.standalone" depends="generate-method-classes, serialize.rubylib, jar"
+ <target name="jar.standalone" depends="generate-method-classes, jar"
description="Create a standalone jruby.jar file using libraries from RUBY_HOME/lib/ruby/1.8"/>
<target name="compile-test" depends="jar" description="Compile the unit tests">
View
4 src/org/jruby/Ruby.java
@@ -263,6 +263,10 @@ public static Ruby newInstance(InputStream in, PrintStream out, PrintStream err)
return newInstance(config);
}
+ public IRubyObject evalScript(Reader reader, String name) {
+ return eval(parse(reader, name, getCurrentContext().getCurrentScope(), 0));
+ }
+
/**
* Evaluates a script and returns a RubyObject.
*/
View
13 src/org/jruby/runtime/load/LoadService.java
@@ -58,13 +58,12 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.BuiltinScript;
import org.jruby.util.JRubyFile;
-import org.jruby.util.PreparsedScript;
/**
* <b>How require works in JRuby</b>
* When requiring a name from Ruby, JRuby will first remove any file extension it knows about,
* thereby making it possible to use this string to see if JRuby has already loaded
- * the name in question. If a .rb or .rb.ast.ser extension is specified, JRuby will only try
+ * the name in question. If a .rb extension is specified, JRuby will only try
* those extensions when searching. If a .so, .o, .dll, or .jar extension is specified, JRuby
* will only try .so or .jar when searching. Otherwise, JRuby goes through the known suffixes
* (.rb, .rb.ast.ser, .so, and .jar) and tries to find a library with this name. The process for finding a library follows this order
@@ -122,10 +121,10 @@
public class LoadService {
protected static final String JRUBY_BUILTIN_SUFFIX = ".rb";
- protected static final String[] sourceSuffixes = { ".rb", ".rb.ast.ser" };
+ protected static final String[] sourceSuffixes = { ".rb" };
protected static final String[] extensionSuffixes = { ".so", ".jar" };
- protected static final String[] allSuffixes = { ".rb", ".rb.ast.ser", ".so", ".jar" };
- protected static final Pattern sourcePattern = Pattern.compile("\\.(?:rb|rb\\.ast\\.ser)$");
+ protected static final String[] allSuffixes = { ".rb", ".so", ".jar" };
+ protected static final Pattern sourcePattern = Pattern.compile("\\.(?:rb)$");
protected static final Pattern extensionPattern = Pattern.compile("\\.(?:so|o|dll|jar)$");
protected final RubyArray loadPath;
@@ -382,8 +381,6 @@ private Library findLibrary(String file) {
if (file.endsWith(".jar")) {
return new JarredScript(resource);
- } else if (file.endsWith(".rb.ast.ser")) {
- return new PreparsedScript(resource);
} else {
return new ExternalScript(resource, file);
}
@@ -397,8 +394,6 @@ private Library findLibraryWithClassloaders(String file) {
if (file.endsWith(".jar")) {
return new JarredScript(resource);
- } else if (file.endsWith(".rb.ast.ser")) {
- return new PreparsedScript(resource);
} else {
return new ExternalScript(resource, file);
}
View
28 src/org/jruby/util/BuiltinScript.java
@@ -30,18 +30,16 @@
***** END LICENSE BLOCK *****/
package org.jruby.util;
-import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
-import org.ablaf.ast.IAstDecoder;
import org.jruby.Ruby;
-import org.jruby.ast.Node;
-import org.jruby.ast.util.RubyAstMarshal;
import org.jruby.runtime.load.Library;
/**
- * Loading of pre-parsed, serialized, Ruby scripts that are built into JRuby.
+ * Loading of Ruby scripts that are built into JRuby.
*/
public class BuiltinScript implements Library {
private final String name;
@@ -51,21 +49,11 @@ public BuiltinScript(String name) {
}
public void load(Ruby runtime) throws IOException {
- runtime.loadNode("jruby builtin", getNode(runtime));
- }
-
- private Node getNode(Ruby runtime) throws IOException {
- String resourceName = "/builtin/" + name + ".rb.ast.ser";
+ String resourceName = "/builtin/" + name + ".rb";
InputStream in = getClass().getResourceAsStream(resourceName);
- if (in == null) {
- throw runtime.newIOError("Resource not found: " + resourceName);
- }
- in = new BufferedInputStream(in);
- IAstDecoder decoder = RubyAstMarshal.getInstance().openDecoder(in);
- try {
- return decoder.readNode();
- } finally {
- decoder.close();
- }
+
+ if (in == null) throw runtime.newIOError("Resource not found: " + resourceName);
+
+ runtime.evalScript(new BufferedReader(new InputStreamReader(in)), name);
}
}
View
70 src/org/jruby/util/PreparsedScript.java
@@ -1,70 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com>
- * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-package org.jruby.util;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.ablaf.ast.IAstDecoder;
-import org.jruby.Ruby;
-import org.jruby.ast.Node;
-import org.jruby.ast.util.RubyAstMarshal;
-import org.jruby.runtime.load.Library;
-import org.jruby.runtime.load.LoadServiceResource;
-
-/**
- * Loading of pre-parsed, serialized, Ruby scripts that are built into JRuby.
- */
-public class PreparsedScript implements Library {
- private LoadServiceResource resource;
-
- public PreparsedScript(LoadServiceResource resource) {
- this.resource = resource;
- }
-
- public void load(Ruby runtime) throws IOException {
- runtime.loadNode("preparsed", getNode(runtime));
- }
-
- private Node getNode(Ruby runtime) throws IOException {
- InputStream in;
- try {
- in = new BufferedInputStream(resource.getURL().openStream());
- } catch (IOException e) {
- throw runtime.newIOError("Resource not found: " + resource.getName());
- }
- IAstDecoder decoder = RubyAstMarshal.getInstance().openDecoder(in);
- try {
- return decoder.readNode();
- } finally {
- decoder.close();
- }
- }
-}
View
139 src/org/jruby/util/ant/JRubySerialize.java
@@ -1,139 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de>
- * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com>
- * Copyright (C) 2004 Anders Bengtsson <ndrsbngtssn@yahoo.se>
- * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-package org.jruby.util.ant;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Mapper;
-import org.apache.tools.ant.util.FileNameMapper;
-import org.apache.tools.ant.util.GlobPatternMapper;
-import org.apache.tools.ant.util.SourceFileScanner;
-import org.jruby.main.ASTSerializer;
-
-/**
- *
- * @author jpetersen
- */
-public class JRubySerialize extends Task {
- private File destdir = null;
- private boolean verbose = false;
-
- private List fileSets = new ArrayList();
- private Mapper mapperElement = null;
-
- public void execute() throws BuildException {
- Map fileMap = new HashMap();
-
- FileNameMapper mapper = null;
- if (mapperElement != null) {
- mapper = mapperElement.getImplementation();
- } else {
- mapper = new GlobPatternMapper();
- mapper.setFrom("*.rb");
- mapper.setTo("*.rb.ast.ser");
- }
-
- SourceFileScanner sfs = new SourceFileScanner(this);
-
- for (int i = 0, size = fileSets.size(); i < size; i++) {
- FileSet fs = (FileSet) fileSets.get(i);
- DirectoryScanner ds = fs.getDirectoryScanner(getProject());
-
- File dir = fs.getDir(getProject());
- String[] files = ds.getIncludedFiles();
-
- files = sfs.restrict(files, dir, destdir, mapper);
-
- for (int j = 0; j < files.length; j++) {
- File src = new File(dir, files[j]);
- File dest = new File(destdir, mapper.mapFileName(files[j])[0]);
- fileMap.put(src, dest);
- }
- }
-
- if (fileMap.size() > 0) {
- log(
- "Serializing "
- + fileMap.size()
- + " file"
- + (fileMap.size() == 1 ? "" : "s")
- + " to "
- + destdir.getAbsolutePath());
-
- Iterator iter = fileMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- try {
- ((File) entry.getValue()).getParentFile().mkdirs();
- if (verbose) System.out.println(entry.getKey());
- ASTSerializer.serialize((File) entry.getKey(), (File) entry.getValue());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public void setDestdir(File destdir) {
- this.destdir = destdir;
- }
-
- /**
- * Adds a set of files to copy.
- */
- public void addFileset(FileSet set) {
- fileSets.add(set);
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- /**
- * Defines the mapper to map source to destination files.
- */
- public Mapper createMapper() throws BuildException {
- if (mapperElement != null) {
- throw new BuildException("Cannot define more than one mapper", getLocation());
- }
- mapperElement = new Mapper(getProject());
- return mapperElement;
- }
-}

0 comments on commit 44da7d7

Please sign in to comment.
Something went wrong with that request. Please try again.