Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

DirectedGraph Specs : Removing a vertex doesn't remove edges from the graph #303

Closed
wants to merge 32 commits into from

7 participants

@prathamesh-sonpatki

Removing a vertex from a graph doesn't remove the edges from the graph itself. So after removing edges associated with vertex, i deleted it from the associated graph also.

Prathamesh S... and others added some commits
Prathamesh Sonpatki Added Bootstrap information to spec b73104e
Prathamesh Sonpatki Added test for checking class of newly created object 89f3b32
@kares kares no need to report memory/stack as properties
as they are resolved from RuntimeMXBean (see 5d86783)
3f058b5
@headius headius Update to working i386 Windows jffi. 33e419c
Prathamesh Sonpatki Added tests for adding and removing edges d4ed05c
Prathamesh Sonpatki Removed type checking spec 3d4456d
Prathamesh Sonpatki Fixed removing of edges after deleting a vertex 1db8341
@tychobrailleur tychobrailleur Fix for issue #276
This commit fixes issue #276 which is a regression introduced by
http://jira.codehaus.org/browse/JRUBY-6729.  The bug was caused by a erroneous
behavour when yielding splat for a block of arity of one: MRI doesn't unsplat
the passed value, whilst jruby was.

See GH-276_yield_splat_behaviour_causes_pp_to_break.rb for details on behaviour
615e3a4
@enebo enebo toString should work under normal conditions 823990a
@headius headius Modifications to bring our RubyGems more in line with original.
* Removed Maven support.
* Have 'gem' just load 'jgem' in the same dir, since that's the
one that RubyGems updates.
ec3e8e5
@headius headius Fix shebang. 2b11fee
@enebo enebo trivial 5276cd5
@enebo enebo Allow java proxy class to be overriden for Android support ffa26ea
@donv donv * Removed gem/Manifest.txt since it is a generated file 1abba3f
@donv donv * Removed gem/Manifest.txt since it is a generated file 08ba732
@donv donv * JRUBY-6883 Enable subclassing of Java classes on Dalvik
* Made JavaProxyClassFactory#invokeDefineClass protected to enable overriding it.
* Removed unused import.
* Added logging of custom proxy class factory.  Quiet for default.
69a302f
@donv donv * JRUBY-6883 Change System.out/err.println to Logger.info/error to en…
…able log filtering
3e6064d
@enebo enebo Bump for new version of jffi eb1e729
@enebo enebo Up the dose on windows JRE 09fa430
@BanzaiMan BanzaiMan Fix JRUBY-6892: Calling #drop on an Enumerator doesn't work properly
When "drop" is called on an Enumerator, the memory locations for the members of the return value were reused.
This resulted in a wrong result that the ticket describes. We address the problem by calling dup() whenever appropriate.
ebd0b8e
@BanzaiMan BanzaiMan tzdata 2012f was released on September 13, 2012 83a8c97
@headius headius The accept method should never raise. c530c84
@headius headius Performance improvements for defined? logic.
* Return a cached, frozen string rather than recreating each time.
* Cache variable accessors for ivar defined? checks.
d6993e4
@headius headius Improve interpreted DStr by avoiding transient strings.
For an expression like "foo#{i}bar" we sometimes would create the
"foo" and "bar" strings only to concatenate them. For interpreter,
this only occurred if encodings were different, which was rare. I
fix that in this commit to always use the "foo" and "bar" ByteList
directly.

Compiler still creates "foo" and "bar" all the time. That must be
fixed.
369226e
@headius headius Improvements for DStr/DSymbol interpretation for #301.
* Special-case core classes in RubyString.append19 to avoid
dyncalls and transient objects.
* Special-case core classes in DNode's EvStr handling to use
append19 directly rather than coercing to a throw-away transient
String.
* Don't create a shared string in DNode, since it's a new ByteList
that's almost immediately written to anyway.
* DSymbol knows super will produce a String, so use more direct
path that doesn't immediately convert to Java String. See #300.
4a5e311
@headius headius Fix compile error. I must not have done a clean build. 71fa23b
@headius headius Eliminate most transient strings in compiled D*Nodes.
* Static portions are cached bytelist, direct append.
* EvStr with Fixnum/Float/Symbol body append object directly.
* Remaining cases coerce to String as before.
0ec6270
@headius headius Eliminate transient strings from compiled DSymbol, DXStr logic.
Same general pattern as for DStr. See #301.
eb59845
@headius headius Add a CHM to SymbolTable for Bytelist => Symbol. Fixes #300. a914eb9
@headius headius Fix defined?(@foo) when @foo has been assigned nil. 2998175
@headius headius Simplify constant and ivar defined? logic in the compiler. 970afc1
@headius headius Additional fix to go with #276 and its fix #293.
* Compiler needed the same logic.
* Invalid block needs to be checked or arity().getValue will NPE.
dc19d5d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 9, 2012
  1. Added Bootstrap information to spec

    Prathamesh Sonpatki authored
  2. Added test for checking class of newly created object

    Prathamesh Sonpatki authored
Commits on Sep 10, 2012
  1. @kares

    no need to report memory/stack as properties

    kares authored Prathamesh Sonpatki committed
    as they are resolved from RuntimeMXBean (see 5d86783)
Commits on Sep 12, 2012
  1. @headius

    Update to working i386 Windows jffi.

    headius authored Prathamesh Sonpatki committed
Commits on Sep 17, 2012
  1. Added tests for adding and removing edges

    Prathamesh Sonpatki authored
Commits on Sep 18, 2012
  1. Removed type checking spec

    Prathamesh Sonpatki authored
  2. Fixed removing of edges after deleting a vertex

    Prathamesh Sonpatki authored
  3. @tychobrailleur

    Fix for issue #276

    tychobrailleur authored Prathamesh Sonpatki committed
    This commit fixes issue #276 which is a regression introduced by
    http://jira.codehaus.org/browse/JRUBY-6729.  The bug was caused by a erroneous
    behavour when yielding splat for a block of arity of one: MRI doesn't unsplat
    the passed value, whilst jruby was.
    
    See GH-276_yield_splat_behaviour_causes_pp_to_break.rb for details on behaviour
  4. @enebo

    toString should work under normal conditions

    enebo authored Prathamesh Sonpatki committed
  5. @headius

    Modifications to bring our RubyGems more in line with original.

    headius authored Prathamesh Sonpatki committed
    * Removed Maven support.
    * Have 'gem' just load 'jgem' in the same dir, since that's the
    one that RubyGems updates.
  6. @headius

    Fix shebang.

    headius authored Prathamesh Sonpatki committed
  7. @enebo

    trivial

    enebo authored Prathamesh Sonpatki committed
  8. @enebo

    Allow java proxy class to be overriden for Android support

    enebo authored Prathamesh Sonpatki committed
  9. @donv

    * Removed gem/Manifest.txt since it is a generated file

    donv authored Prathamesh Sonpatki committed
  10. @donv

    * Removed gem/Manifest.txt since it is a generated file

    donv authored Prathamesh Sonpatki committed
  11. @donv

    * JRUBY-6883 Enable subclassing of Java classes on Dalvik

    donv authored Prathamesh Sonpatki committed
    * Made JavaProxyClassFactory#invokeDefineClass protected to enable overriding it.
    * Removed unused import.
    * Added logging of custom proxy class factory.  Quiet for default.
  12. @donv

    * JRUBY-6883 Change System.out/err.println to Logger.info/error to en…

    donv authored Prathamesh Sonpatki committed
    …able log filtering
  13. @enebo

    Bump for new version of jffi

    enebo authored Prathamesh Sonpatki committed
  14. @enebo

    Up the dose on windows JRE

    enebo authored Prathamesh Sonpatki committed
  15. @BanzaiMan

    Fix JRUBY-6892: Calling #drop on an Enumerator doesn't work properly

    BanzaiMan authored Prathamesh Sonpatki committed
    When "drop" is called on an Enumerator, the memory locations for the members of the return value were reused.
    This resulted in a wrong result that the ticket describes. We address the problem by calling dup() whenever appropriate.
  16. @BanzaiMan

    tzdata 2012f was released on September 13, 2012

    BanzaiMan authored Prathamesh Sonpatki committed
  17. @headius

    The accept method should never raise.

    headius authored Prathamesh Sonpatki committed
  18. @headius

    Performance improvements for defined? logic.

    headius authored Prathamesh Sonpatki committed
    * Return a cached, frozen string rather than recreating each time.
    * Cache variable accessors for ivar defined? checks.
  19. @headius

    Improve interpreted DStr by avoiding transient strings.

    headius authored Prathamesh Sonpatki committed
    For an expression like "foo#{i}bar" we sometimes would create the
    "foo" and "bar" strings only to concatenate them. For interpreter,
    this only occurred if encodings were different, which was rare. I
    fix that in this commit to always use the "foo" and "bar" ByteList
    directly.
    
    Compiler still creates "foo" and "bar" all the time. That must be
    fixed.
  20. @headius

    Improvements for DStr/DSymbol interpretation for #301.

    headius authored Prathamesh Sonpatki committed
    * Special-case core classes in RubyString.append19 to avoid
    dyncalls and transient objects.
    * Special-case core classes in DNode's EvStr handling to use
    append19 directly rather than coercing to a throw-away transient
    String.
    * Don't create a shared string in DNode, since it's a new ByteList
    that's almost immediately written to anyway.
    * DSymbol knows super will produce a String, so use more direct
    path that doesn't immediately convert to Java String. See #300.
  21. @headius

    Fix compile error. I must not have done a clean build.

    headius authored Prathamesh Sonpatki committed
  22. @headius

    Eliminate most transient strings in compiled D*Nodes.

    headius authored Prathamesh Sonpatki committed
    * Static portions are cached bytelist, direct append.
    * EvStr with Fixnum/Float/Symbol body append object directly.
    * Remaining cases coerce to String as before.
  23. @headius

    Eliminate transient strings from compiled DSymbol, DXStr logic.

    headius authored Prathamesh Sonpatki committed
    Same general pattern as for DStr. See #301.
  24. @headius

    Add a CHM to SymbolTable for Bytelist => Symbol. Fixes #300.

    headius authored Prathamesh Sonpatki committed
  25. @headius

    Fix defined?(@foo) when @foo has been assigned nil.

    headius authored Prathamesh Sonpatki committed
  26. @headius

    Simplify constant and ivar defined? logic in the compiler.

    headius authored Prathamesh Sonpatki committed
  27. @headius

    Additional fix to go with #276 and its fix #293.

    headius authored Prathamesh Sonpatki committed
    * Compiler needed the same logic.
    * Invalid block needs to be checked or arity().getValue will NPE.
This page is out of date. Refresh to see the latest.
Showing with 887 additions and 1,073 deletions.
  1. +1 −0  .gitignore
  2. +2 −23 bin/gem
  3. +9 −0 bin/jgem
  4. +1 −4 bin/jruby.sh
  5. BIN  build_lib/jffi-i386-Windows.jar
  6. +1 −1  default.build.properties
  7. +0 −7 gem/Manifest.txt
  8. +2 −2 install/jruby.install4j
  9. +6 −6 lib/ruby/shared/rubygems/local_remote_options.rb
  10. +0 −376 lib/ruby/shared/rubygems/maven_gemify.rb
  11. +0 −5 lib/ruby/shared/rubygems/remote_fetcher.rb
  12. +3 −13 lib/ruby/shared/rubygems/spec_fetcher.rb
  13. +1 −1  maven/pom.xml
  14. +43 −0 spec/ir/directed_graph/directed_graph_spec.rb
  15. +0 −100 spec/java_integration/rubygems/maven_gemify_spec.rb
  16. +55 −0 spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb
  17. +10 −0 spec/regression/JRUBY-6892_drop_on_enumerator_oddity_spec.rb
  18. +3 −9 src/org/jruby/Main.java
  19. +31 −13 src/org/jruby/Ruby.java
  20. +4 −1 src/org/jruby/RubyEnumerable.java
  21. +15 −2 src/org/jruby/RubyString.java
  22. +16 −2 src/org/jruby/RubySymbol.java
  23. +4 −2 src/org/jruby/ast/AndNode.java
  24. +1 −1  src/org/jruby/ast/ArgumentNode.java
  25. +4 −2 src/org/jruby/ast/AssignableNode.java
  26. +4 −2 src/org/jruby/ast/AttrAssignNode.java
  27. +6 −4 src/org/jruby/ast/BackRefNode.java
  28. +3 −3 src/org/jruby/ast/CallNoArgNode.java
  29. +4 −2 src/org/jruby/ast/CallNode.java
  30. +6 −5 src/org/jruby/ast/ClassVarNode.java
  31. +7 −2 src/org/jruby/ast/Colon2ConstNode.java
  32. +2 −1  src/org/jruby/ast/Colon2ImplicitNode.java
  33. +6 −2 src/org/jruby/ast/Colon2MethodNode.java
  34. +5 −3 src/org/jruby/ast/Colon3Node.java
  35. +4 −2 src/org/jruby/ast/ConstNode.java
  36. +27 −9 src/org/jruby/ast/DNode.java
  37. +5 −1 src/org/jruby/ast/DSymbolNode.java
  38. +5 −3 src/org/jruby/ast/DVarNode.java
  39. +2 −2 src/org/jruby/ast/DefinedNode.java
  40. +10 −2 src/org/jruby/ast/FCallNode.java
  41. +4 −2 src/org/jruby/ast/FalseNode.java
  42. +4 −2 src/org/jruby/ast/GlobalVarNode.java
  43. +17 −6 src/org/jruby/ast/InstVarNode.java
  44. +4 −2 src/org/jruby/ast/LocalVarNode.java
  45. +4 −2 src/org/jruby/ast/Match2Node.java
  46. +3 −2 src/org/jruby/ast/Match3Node.java
  47. +2 −1  src/org/jruby/ast/NewlineNode.java
  48. +4 −2 src/org/jruby/ast/NilNode.java
  49. +4 −2 src/org/jruby/ast/Node.java
  50. +3 −2 src/org/jruby/ast/NotNode.java
  51. +7 −5 src/org/jruby/ast/NthRefNode.java
  52. +4 −2 src/org/jruby/ast/OpAsgnAndNode.java
  53. +4 −2 src/org/jruby/ast/OpAsgnOrNode.java
  54. +4 −2 src/org/jruby/ast/OrNode.java
  55. +4 −2 src/org/jruby/ast/SelfNode.java
  56. +4 −2 src/org/jruby/ast/SuperNode.java
  57. +4 −2 src/org/jruby/ast/TrueNode.java
  58. +4 −2 src/org/jruby/ast/VCallNode.java
  59. +3 −2 src/org/jruby/ast/Yield19Node.java
  60. +4 −2 src/org/jruby/ast/YieldNode.java
  61. +4 −2 src/org/jruby/ast/ZSuperNode.java
  62. +24 −0 src/org/jruby/ast/executable/AbstractScript.java
  63. +22 −9 src/org/jruby/ast/executable/RuntimeCache.java
  64. +65 −195 src/org/jruby/compiler/ASTCompiler.java
  65. +5 −4 src/org/jruby/compiler/ASTCompiler19.java
  66. +31 −2 src/org/jruby/compiler/BodyCompiler.java
  67. +4 −0 src/org/jruby/compiler/CacheCompiler.java
  68. +65 −44 src/org/jruby/compiler/impl/BaseBodyCompiler.java
  69. +30 −0 src/org/jruby/compiler/impl/InheritedCacheCompiler.java
  70. +3 −2 src/org/jruby/compiler/impl/StandardInvocationCompiler.java
  71. +1 −1  src/org/jruby/evaluator/ASTInterpreter.java
  72. +3 −2 src/org/jruby/ir/instructions/defined/GetDefinedConstantOrMethodInstr.java
  73. +2 −2 src/org/jruby/ir/instructions/defined/MethodDefinedInstr.java
  74. +2 −0  src/org/jruby/ir/util/Vertex.java
  75. +5 −0 src/org/jruby/javasupport/Java.java
  76. +2 −2 src/org/jruby/javasupport/proxy/JavaProxyClass.java
  77. +97 −117 src/org/jruby/javasupport/proxy/JavaProxyClassFactory.java
  78. +39 −30 src/org/jruby/javasupport/util/RuntimeHelpers.java
  79. +1 −1  src/org/jruby/lexer/yacc/InputStreamLexerSource.java
  80. +16 −1 src/org/jruby/runtime/callsite/CachingCallSite.java
  81. +60 −0 src/org/jruby/util/DefinedMessage.java
  82. +1 −0  src/org/jruby/util/cli/Options.java
  83. +6 −0 test/externals/ruby1.9/test_pp.rb
View
1  .gitignore
@@ -23,6 +23,7 @@ src_gen
docs/api
test/rails
test/prawn
+gem/Manifest.txt
gem/lib/*.jar
gem/lib/jruby-jars/version.rb
gem/pkg
View
25 bin/gem
@@ -1,25 +1,4 @@
#!/usr/bin/env jruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-require 'rubygems/gem_runner'
-require 'rubygems/exceptions'
-
-required_version = Gem::Requirement.new ">= 1.8.7"
-
-unless required_version.satisfied_by? Gem.ruby_version then
- abort "Expected Ruby Version #{required_version}, is #{Gem.ruby_version}"
-end
-
-args = ARGV.clone
-
-begin
- Gem::GemRunner.new.run args
-rescue Gem::SystemExitException => e
- exit e.exit_code
-end
+# We just load jgem, since that's what RubyGems updates
+load File.join(File.dirname(__FILE__), "jgem")
View
9 bin/jgem
@@ -5,6 +5,15 @@
# See LICENSE.txt for permissions.
#++
+# The prelude in 1.9.1 injects rubygems.rb into $LOADED_FEATURES
+# which prevents the `require 'rubygems'` from actually loading
+# the site's version of rubygems. So we have to use it's API
+# to get it's prelude out of the way.
+#
+if RUBY_VERSION =~ /^1\.9\.1/ && defined?(Gem::QuickLoader)
+ Gem::QuickLoader.load_full_rubygems_library
+end
+
require 'rubygems'
require 'rubygems/gem_runner'
require 'rubygems/exceptions'
View
5 bin/jruby.sh
@@ -248,16 +248,13 @@ if [[ -z "$JAVA_ENCODING" ]]; then
java_args="${java_args} -Dfile.encoding=UTF-8"
fi
-# Add a property to report memory max
-JAVA_OPTS="$JAVA_OPTS $JAVA_VM -Djruby.memory.max=${JAVA_MEM} -Djruby.stack.max=${JAVA_STACK}"
-
# Append the rest of the arguments
ruby_args="${ruby_args} $@"
# Put the ruby_args back into the position arguments $1, $2 etc
set -- "${ruby_args}"
-JAVA_OPTS="$JAVA_OPTS $JAVA_MEM $JAVA_STACK"
+JAVA_OPTS="$JAVA_OPTS $JAVA_VM $JAVA_MEM $JAVA_STACK"
JFFI_BOOT=""
if [ -d "$JRUBY_HOME/lib/native/" ]; then
View
BIN  build_lib/jffi-i386-Windows.jar
Binary file not shown
View
2  default.build.properties
@@ -92,7 +92,7 @@ tzdata.ftpserver=ftp.iana.org
tzdata.ftp.dir=/tz/releases
tzdata.ftp.anonymous.userid=jruby@jruby.org
tzdata.distributed.version=2011n
-tzdata.latest.version=2012e
+tzdata.latest.version=2012f
jline.version=2.7
asm.version=4.0
shared.lib.dir=lib/ruby/shared
View
7 gem/Manifest.txt
@@ -1,7 +0,0 @@
-History.txt
-Manifest.txt
-README.txt
-lib/jruby-jars.rb
-lib/jruby-jars/version.rb
-lib/jruby-core-1.7.0.dev.jar
-lib/jruby-stdlib-1.7.0.dev.jar
View
4 install/jruby.install4j
@@ -704,7 +704,7 @@
</exclude>
<variables />
</win32>
- <win32 name="Windows w/ JRE" id="21" mediaFileName="${compiler:sys.shortName}_${compiler:sys.platform}jre_${compiler:sys.version}" installDir="jruby-${compiler:sys.version}" overridePrincipalLanguage="false" requires64bit="false" jreBitType="32" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" includedJRE="windows-x86-1.7.0_05" manualJREEntry="false" bundleType="1" jreURL="" jreFtpURL="" jreShared="false" directDownload="false" customInstallBaseDir="c:" createUninstallIcon="true" contentFilesType="1" downloadURL="" runAsAdmin="false">
+ <win32 name="Windows w/ JRE" id="21" mediaFileName="${compiler:sys.shortName}_${compiler:sys.platform}jre_${compiler:sys.version}" installDir="jruby-${compiler:sys.version}" overridePrincipalLanguage="false" requires64bit="false" jreBitType="32" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" includedJRE="windows-x86-1.7.0_07" manualJREEntry="false" bundleType="1" jreURL="" jreFtpURL="" jreShared="false" directDownload="false" customInstallBaseDir="c:" createUninstallIcon="true" contentFilesType="1" downloadURL="" runAsAdmin="false">
<excludedLaunchers />
<excludedComponents />
<excludedBeans>
@@ -716,7 +716,7 @@
</exclude>
<variables />
</win32>
- <win32 name="Windows 64-bit w/ JRE" id="198" mediaFileName="${compiler:sys.shortName}_${compiler:sys.platform}_x64_jre_${compiler:sys.version}" installDir="jruby-${compiler:sys.version}" overridePrincipalLanguage="false" requires64bit="true" jreBitType="64" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" includedJRE="windows-amd64-1.7.0_05" manualJREEntry="false" bundleType="1" jreURL="" jreFtpURL="" jreShared="false" directDownload="false" customInstallBaseDir="c:" createUninstallIcon="true" contentFilesType="1" downloadURL="" runAsAdmin="false">
+ <win32 name="Windows 64-bit w/ JRE" id="198" mediaFileName="${compiler:sys.shortName}_${compiler:sys.platform}_x64_jre_${compiler:sys.version}" installDir="jruby-${compiler:sys.version}" overridePrincipalLanguage="false" requires64bit="true" jreBitType="64" runPostProcessor="false" postProcessor="" failOnPostProcessorError="false" includedJRE="windows-amd64-1.7.0_07" manualJREEntry="false" bundleType="1" jreURL="" jreFtpURL="" jreShared="false" directDownload="false" customInstallBaseDir="c:" createUninstallIcon="true" contentFilesType="1" downloadURL="" runAsAdmin="false">
<excludedLaunchers />
<excludedComponents />
<excludedBeans>
View
12 lib/ruby/shared/rubygems/local_remote_options.rb
@@ -15,15 +15,15 @@ module Gem::LocalRemoteOptions
##
# Allows OptionParser to handle HTTP URIs.
- def accept_uri http = nil
- OptionParser.accept(http ? URI::HTTP : URI::Generic) do |value|
+ def accept_uri_http
+ OptionParser.accept URI::HTTP do |value|
begin
uri = URI.parse value
rescue URI::InvalidURIError
raise OptionParser::InvalidArgument, value
end
- if http && !['http', 'https', 'file'].include?(uri.scheme)
+ unless ['http', 'https', 'file'].include?(uri.scheme)
raise OptionParser::InvalidArgument, value
end
@@ -85,7 +85,7 @@ def add_clear_sources_option
# Add the --http-proxy option
def add_proxy_option
- accept_uri :http
+ accept_uri_http
add_option(:"Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP,
'Use HTTP proxy for remote operations') do |value, options|
@@ -98,9 +98,9 @@ def add_proxy_option
# Add the --source option
def add_source_option
- accept_uri
+ accept_uri_http
- add_option(:"Local/Remote", '--source URL', URI::Generic,
+ add_option(:"Local/Remote", '--source URL', URI::HTTP,
'Add URL as a remote source for gems') do |source, options|
source << '/' if source !~ /\/\z/
View
376 lib/ruby/shared/rubygems/maven_gemify.rb
@@ -1,376 +0,0 @@
-require 'uri'
-require 'rubygems/remote_fetcher'
-
-module Gem
- module MavenUtils
- def maven_name?(name)
- name = name.source.sub(/\^/, '') if Regexp === name
- name =~ /^mvn:/
- end
-
- def maven_source_uri?(source_uri)
- source_uri.scheme == "mvn" || source_uri.host == "maven"
- end
-
- def maven_sources
- Gem.sources.select {|x| x =~ /^mvn:/}
- end
-
- def maven_spec?(gemname, source_uri)
- maven_name?(gemname) && maven_source_uri?(source_uri)
- end
- end
-
- class Maven3NotFound < StandardError; end
-
- class RemoteFetcher
- include MavenUtils
-
- def download_maven(spec, local_gem_path)
- FileUtils.cp Gem::Maven::Gemify.new(maven_sources).generate_gem(spec.name, spec.version), local_gem_path
- local_gem_path
- end
- private :download_maven
- end
-
- class SpecFetcher
- include MavenUtils
-
- alias orig_find_matching_with_errors find_matching_with_errors
- def find_matching_with_errors(dependency, all = false, matching_platform = true, prerelease = false)
- if maven_name? dependency.name
- begin
- result = maven_find_matching_with_errors(dependency)
- rescue Gem::Maven3NotFound => e
- raise e
- rescue => e
- warn "maven find dependency failed for #{dependency}: #{e.to_s}" if Gem::Maven::Gemify.verbose?
- end
- end
- if result && !result.flatten.empty?
- result
- else
- orig_find_matching_with_errors(dependency, all, matching_platform, prerelease)
- end
- end
-
- alias orig_list list
- def list(*args)
- sources = Gem.sources
- begin
- Gem.sources -= maven_sources
- return orig_list(*args)
- ensure
- Gem.sources = sources
- end
- end
-
- alias orig_load_specs load_specs
- def load_specs(source_uri, file)
- return if source_uri.scheme == "mvn"
- orig_load_specs(source_uri, file)
- end
-
- private
- def maven_generate_spec(spec)
- specfile = Gem::Maven::Gemify.new(maven_sources).generate_spec(spec[0], spec[1])
- return nil unless specfile
- Marshal.dump(Gem::Specification.from_yaml(File.read(specfile)))
- end
-
- # use maven to locate (generate) the specification for the dependency in question
- def maven_find_matching_with_errors(dependency)
- specs_and_sources = []
- if dependency.name.is_a? Regexp
- dep_name = dependency.name.source.sub(/\^/, '')
- else
- dep_name = dependency.name
- end
-
- Gem::Maven::Gemify.new(maven_sources).get_versions(dep_name).each do |version|
- # maven-versions which start with an letter get "0.0.0." prepended to
- # satisfy gem-version requirements
- if dependency.requirement.satisfied_by? Gem::Version.new "#{version.sub(/^0.0.0./, '1.')}"
- specs_and_sources.push [[dep_name, version, "java"], "http://maven/"]
- end
- end
-
- [specs_and_sources, []]
- end
- end
-
- module Maven
- class Gemify
- DEFAULT_PLUGIN_VERSION = "0.26.0"
-
- attr_reader :repositories
-
- def initialize(*repositories)
- maven # ensure maven initialized
- @repositories = repositories.length > 0 ? [repositories].flatten : []
- @repositories.map! do |r|
- u = URI === r ? r : URI.parse(r)
- if u.scheme == "mvn"
- if u.opaque == "central"
- u = nil
- else
- u.scheme = "http"
- end
- end
- u
- end
- end
-
- @@verbose = false
- def self.verbose?
- @@verbose || $DEBUG
- end
- def verbose?
- self.class.verbose?
- end
- def self.verbose=(v)
- @@verbose = v
- end
-
- private
- def self.maven_config
- @maven_config ||= Gem.configuration["maven"] || {}
- end
- def maven_config; self.class.maven_config; end
-
- def self.base_goal
- @base_goal ||= "de.saumya.mojo:gemify-maven-plugin:#{maven_config['plugin_version'] || DEFAULT_PLUGIN_VERSION}"
- end
- def base_goal; self.class.base_goal; end
-
- def self.java_imports
- %w(
- org.codehaus.plexus.classworlds.ClassWorld
- org.codehaus.plexus.DefaultContainerConfiguration
- org.codehaus.plexus.DefaultPlexusContainer
- org.apache.maven.Maven
- org.apache.maven.repository.RepositorySystem
- org.apache.maven.execution.DefaultMavenExecutionRequest
- org.apache.maven.artifact.repository.MavenArtifactRepository
- org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout
- org.apache.maven.artifact.repository.ArtifactRepositoryPolicy
- ).each {|i| java_import i }
- end
-
- def self.create_maven
- require 'java' # done lazily, so we're not loading it all the time
- bin = nil
- if ENV['M2_HOME'] # use M2_HOME if set
- bin = File.join(ENV['M2_HOME'], "bin")
- else
- ENV['PATH'].split(File::PATH_SEPARATOR).detect do |path|
- mvn = File.join(path, "mvn")
- if File.exists?(mvn)
- if File.symlink?(mvn)
- link = File.readlink(mvn)
- if link =~ /^\// # is absolute path
- bin = File.dirname(File.expand_path(link))
- else # is relative path so join with dir of the maven command
- bin = File.dirname(File.expand_path(File.join(File.dirname(mvn), link)))
- end
- else # is no link so just expand it
- bin = File.expand_path(path)
- end
- else
- nil
- end
- end
- end
- bin = "/usr/share/maven2/bin" if bin.nil? # OK let's try debian default
- if File.exists?(bin)
- @mvn = File.join(bin, "mvn")
- if Dir.glob(File.join(bin, "..", "lib", "maven-core-3.*jar")).size == 0
- begin
- gem 'ruby-maven', ">=0"
- bin = File.dirname(Gem.bin_path('ruby-maven', "rmvn"))
- @mvn = File.join(bin, "rmvn")
- rescue LoadError
- bin = nil
- end
- end
- else
- bin = nil
- end
- raise Gem::Maven3NotFound.new("can not find maven3 installation. install ruby-maven with\n\n\tjruby -S gem install ruby-maven\n\n") if bin.nil?
-
- warn "Using Maven install at #{bin}" if verbose?
-
- boot = File.join(bin, "..", "boot")
- lib = File.join(bin, "..", "lib")
- ext = File.join(bin, "..", "ext")
- (Dir.glob(lib + "/*jar") + Dir.glob(boot + "/*jar")).each {|path| require path }
-
- java.lang.System.setProperty("classworlds.conf", File.join(bin, "m2.conf"))
- java.lang.System.setProperty("maven.home", File.join(bin, ".."))
- java_imports
-
- class_world = ClassWorld.new("plexus.core", java.lang.Thread.currentThread().getContextClassLoader());
- config = DefaultContainerConfiguration.new
- config.set_class_world class_world
- config.set_name "ruby-tools"
- container = DefaultPlexusContainer.new(config);
- @@execution_request_populator = container.lookup(org.apache.maven.execution.MavenExecutionRequestPopulator.java_class)
-
- @@settings_builder = container.lookup(org.apache.maven.settings.building.SettingsBuilder.java_class )
- container.lookup(Maven.java_class)
- end
-
- def self.maven
- @maven ||= create_maven
- end
- def maven; self.class.maven; end
-
- def self.temp_dir
- @temp_dir ||=
- begin
- f = java.io.File.createTempFile("gemify", "")
- f.delete
- f.mkdir
- f.deleteOnExit
- f.absolute_path
- end
- end
- def temp_dir; self.class.temp_dir; end
-
- def execute(goal, gemname, version, props = {})
- request = DefaultMavenExecutionRequest.new
- request.set_show_errors Gem.configuration.backtrace
- skip_dependencies = (!maven_config["dependencies"]).to_s
- request.user_properties.put("gemify.skipDependencies", skip_dependencies)
- request.user_properties.put("gemify.tempDir", temp_dir)
- request.user_properties.put("gemify.gemname", gemname)
- request.user_properties.put("gemify.version", version.to_s) if version
-
- if maven_config["repositories"]
- maven_config["repositories"].each { |r| @repositories << r }
- end
- if @repositories.size > 0
- request.user_properties.put("gemify.repositories", @repositories.join(","))
- end
-
- props.each do |k,v|
- request.user_properties.put(k.to_s, v.to_s)
- end
- request.set_goals [goal]
- request.set_logging_level 0
-
- settings = setup_settings(maven_config["settings"], request.user_properties)
- @@execution_request_populator.populateFromSettings(request, settings)
- @@execution_request_populator.populateDefaults(request)
-
- if profiles = maven_config["profiles"]
- profiles.each { |profile| request.addActiveProfile(profile) }
- end
- if verbose?
- active_profiles = request.getActiveProfiles.collect{ |p| p.to_s }
- puts "active profiles:\n\t[#{active_profiles.join(', ')}]"
- puts "maven goals:"
- request.goals.each { |g| puts "\t#{g}" }
- puts "system properties:"
- request.getUserProperties.map.each { |k,v| puts "\t#{k} => #{v}" }
- puts
- end
- out = java.lang.System.out
- string_io = java.io.ByteArrayOutputStream.new
- java.lang.System.setOut(java.io.PrintStream.new(string_io))
- result = maven.execute request
- java.lang.System.out = out
-
- result.exceptions.each do |e|
- e.print_stack_trace if request.is_show_errors
- string_io.write(e.get_message.to_java_string.get_bytes)
- end
- string_io.to_s
- end
-
- def setup_settings(user_settings_file, user_props)
- @settings ||=
- begin
- user_settings_file =
- if user_settings_file
- resolve_file(usr_settings_file)
- else
- user_maven_home = java.io.File.new(java.lang.System.getProperty("user.home"), ".m2")
- java.io.File.new(user_maven_home, "settings.xml")
- end
-
- global_settings_file =java.io.File.new(@conf, "settings.xml")
-
- settings_request = org.apache.maven.settings.building.DefaultSettingsBuildingRequest.new
- settings_request.setGlobalSettingsFile(global_settings_file)
- settings_request.setUserSettingsFile(user_settings_file)
- settings_request.setSystemProperties(java.lang.System.getProperties)
- settings_request.setUserProperties(user_props)
-
- settings_result = @@settings_builder.build(settings_request)
- settings_result.effective_settings
- end
- end
-
- def resolve_file(file)
- return nil if file.nil?
- return file if file.isAbsolute
- if file.getPath.startsWith(java.io.File.separator)
- # drive-relative Windows path
- return file.getAbsoluteFile
- else
- return java.io.File.new( java.lang.System.getProperty("user.dir"), file.getPath ).getAbsoluteFile
- end
- end
-
- public
- def get_versions(gemname)
- name = maven_name(gemname)
- result = execute("#{base_goal}:versions", name, nil)
-
- if result =~ /#{name} \[/
- result = result.gsub(/\r?\n/, '').sub(/.*\[/, "").sub(/\]/, '').gsub(/ /, '').split(',')
- puts "versions: #{result.inspect}" if verbose?
- result
- else
- []
- end
- end
-
- def generate_spec(gemname, version)
- result = execute("#{base_goal}:gemify", maven_name(gemname), version, "gemify.onlySpecs" => true)
- path = result.gsub(/\r?\n/, '')
- if path =~ /gemspec: /
- path = path.sub(/.*gemspec: /, '')
- if path.size > 0
- result = File.expand_path(path)
- java.io.File.new(result).deleteOnExit
- result
- end
- end
- end
-
- def generate_gem(gemname, version)
- result = execute("#{base_goal}:gemify", maven_name(gemname), version)
- path = result.gsub(/\r?\n/, '')
- if path =~ /gem: /
-
- path = path.sub(/.*gem: /, '')
- if path.size > 0
- result = File.expand_path(path)
- java.io.File.new(result).deleteOnExit
- result
- end
- else
- warn result.sub(/Failed.*pom:/, '').gsub(/\tmvn/, "\t#{@mvn}")
- raise "error gemify #{gemname}:#{version}"
- end
- end
-
- def maven_name(gemname)
- gemname = gemname.source if Regexp === gemname
- gemname
- end
- end
- end
-end
View
5 lib/ruby/shared/rubygems/remote_fetcher.rb
@@ -118,11 +118,6 @@ def download(spec, source_uri, install_dir = Gem.dir)
URI.escape(source_uri.to_s))
end
- # if it's a maven artifact, use maven to fetch it
- if maven_spec? spec.name, source_uri
- return download_maven(spec, local_gem_path)
- end
-
scheme = source_uri.scheme
# URI.parse gets confused by MS Windows paths with forward slashes.
View
16 lib/ruby/shared/rubygems/spec_fetcher.rb
@@ -116,16 +116,10 @@ def fetch_spec(spec, source_uri)
if File.exist? local_spec then
spec = Gem.read_binary local_spec
else
- spec = if maven_spec?(spec[0], source_uri)
- # from rubygems/maven_gemify.rb
- maven_generate_spec(spec)
- end
- unless spec
- uri.path << '.rz'
+ uri.path << '.rz'
- spec = @fetcher.fetch_path uri
- spec = Gem.inflate spec
- end
+ spec = @fetcher.fetch_path uri
+ spec = Gem.inflate spec
if @update_cache then
FileUtils.mkdir_p cache_dir
@@ -301,7 +295,3 @@ def load_specs(source_uri, file)
end
-# Load rubygems/maven_gemify.rb here because;
-# * want to require only spec_fetcher is required to avoid circular require.
-# * need to require after spec_fetcher and remote_fetcher to override those definitions.
-require 'rubygems/maven_gemify'
View
2  maven/pom.xml
@@ -99,7 +99,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
- <version>1.2.4</version>
+ <version>1.2.5</version>
<scope>runtime</scope>
<classifier>native</classifier>
</dependency>
View
43 spec/ir/directed_graph/directed_graph_spec.rb
@@ -0,0 +1,43 @@
+require 'jruby'
+require 'java'
+require 'rspec'
+import 'org.jruby.ir.util.DirectedGraph'
+# This is spec for Directed Graph Library
+
+describe "Directed Graph Utility" do
+
+ before do
+ @graph = DirectedGraph.new
+ @graph.addEdge(1,2,'simple')
+ @graph.addEdge(2,3,'simple')
+ @graph.addEdge(3,4,'simple')
+ @graph.addEdge(4,1,'simple')
+ end
+
+ it "should add an edge to newly created graph" do
+ @graph.edges.size.should == 4
+ @graph.addEdge(4,5,'simple')
+ @graph.edges.size.should == 5
+ end
+
+ it "should remove an existing edge from a graph" do
+ @graph.edges.size.should == 4
+ @graph.removeEdge(1,2)
+ @graph.edges.size.should == 3
+ end
+
+ it "should not delete a non-existent edge from the graph" do
+ @graph.edges.size.should == 4
+ @graph.removeEdge(2,1)
+ @graph.edges.size.should == 4
+ end
+
+ it "should remove a vertex and its associated edges" do
+ @graph.removeVertexFor(3)
+ @graph.edges.size.should == 2
+ @graph.vertices.size.should == 3
+ @graph.removeVertexFor(2)
+ @graph.vertices.size.should == 2
+ end
+
+end
View
100 spec/java_integration/rubygems/maven_gemify_spec.rb
@@ -1,100 +0,0 @@
-require File.dirname(__FILE__) + "/../spec_helper"
-
-require 'rubygems'
-require 'rubygems/format'
-require 'rubygems/maven_gemify'
-require 'yaml'
-
-begin
- Gem::Maven::Gemify.verbose = true if $DEBUG || ENV['DEBUG']
- Gem::Maven::Gemify.maven
-
- describe Gem::MavenUtils, "maven_name?" do
- include Gem::MavenUtils
- it "matches colon-separated artifacts and needs tp start with 'mvn:'" do
- maven_name?('mvn:commons-lang:commons-lang').should be_true
- end
-
- it "does not match things that look like a windows filename" do
- maven_name?('c:ommons-lang:commons-lang').should be_false
- maven_name?('c:/temp/somefile').should be_false
- end
-
- it "does not match URLs" do
- maven_name?('http://example.com/some.gem').should be_false
- end
- it "does not match without 'mvn:' prefix" do
- maven_name?('commons-lang:commons-lang').should be_false
- end
- end
-
- describe Gem::SpecFetcher do
- it "downloads specs for maven artifacts" do
- matching = Gem::SpecFetcher.fetcher.find_matching Gem::Dependency.new("mvn:commons-lang:commons-lang")
- matching.should_not be_empty
- end
- end
-
- describe Gem::Maven::Gemify do
- it "creates an instance of the Maven class" do
- Gem::Maven::Gemify.maven.should be_kind_of(org.apache.maven.Maven)
- end
-
- it "gets a list of versions for a maven artifact" do
- Gem::Maven::Gemify.new.get_versions("mvn:commons-lang:commons-lang").should include("2.5.0")
- end
-
- it "gets a list of versions for a maven artifact from external repository" do
- Gem::Maven::Gemify.new('https://repository.jboss.org/nexus/content/groups/public-jboss').get_versions("mvn:org.jboss.logging:jboss-logging").should include("3.0.0.b.5")
- end
-
- it "allows use of colons as artifact delimiters" do
- Gem::Maven::Gemify.new.get_versions("mvn:commons-lang:commons-lang").should include("2.5.0")
- end
-
- it "generates a gemspec file for the maven artifact" do
- specfile = Gem::Maven::Gemify.new.generate_spec("mvn:commons-lang:commons-lang", "2.5.0")
- specfile.should_not be_nil
- gemspec = Gem::Specification.from_yaml(File.read(specfile))
- gemspec.name.should == "mvn:commons-lang:commons-lang"
- gemspec.version.should == Gem::Version.new("2.5.0")
- end
-
- it "generates a .gem for the maven artifact" do
- gemfile = Gem::Maven::Gemify.new.generate_gem("mvn:commons-lang:commons-lang", "2.5.0")
- format = Gem::Format.from_file_by_path gemfile
- format.file_entries.detect{|fe| fe[0]["path"] =~ /commons-lang\.jar/}.should be_true
- end
-
- it "generates a spec with a Gem::Dependency list for artifacts with dependencies" do
- specfile = Gem::Maven::Gemify.new.generate_spec("mvn:commons-logging:commons-logging", "1.1.1")
- specfile.should_not be_nil
- gemspec = Gem::Specification.from_yaml(File.read(specfile))
- gemspec.dependencies.length.should == 1
- gemspec.dependencies[0].name.should == 'mvn:junit:junit'
- gemspec.dependencies[0].type.should == :development
- end
-
- it "allows a non-standard maven repository" do
- gemify = Gem::Maven::Gemify.new "http://maven.glassfish.org/content/groups/public/"
- specfile = gemify.generate_spec("mvn:com.sun.akuma:akuma", "1.3")
- specfile.should_not be_nil
- gemspec = Gem::Specification.from_yaml(File.read(specfile))
- gemspec.dependencies.length.should == 1
- gemspec.dependencies[0].name.should == 'mvn:net.java.dev.jna:jna'
- end
-
- it "accepts a variety of string or URI parameters to #initialize" do
- expected = ["http://repository.codehaus.org/"]
- Gem::Maven::Gemify.new("http://repository.codehaus.org/").repositories.map(&:to_s).should == expected
- Gem::Maven::Gemify.new(URI.parse("http://repository.codehaus.org/")).repositories.map(&:to_s).should == expected
- Gem::Maven::Gemify.new(["http://repository.codehaus.org/"]).repositories.map(&:to_s).should == expected
- Gem::Maven::Gemify.new("mvn://repository.codehaus.org/").repositories.map(&:to_s).should == expected
- Gem::Maven::Gemify.new(URI.parse("mvn://repository.codehaus.org/")).repositories.map(&:to_s).should == expected
- Gem::Maven::Gemify.new(URI.parse("mvn:central")).repositories.should == [nil]
- end
- end
-rescue => e
- puts(e, *e.backtrace) if $DEBUG || ENV['DEBUG']
- # Skipping maven specs w/o M3 or ruby-maven gem installed
-end
View
55 spec/regression/GH-276_yield_splat_behaviour_causes_pp_to_break.rb
@@ -0,0 +1,55 @@
+require 'rspec'
+
+def call_one
+ yield(["a"])
+end
+
+def call_two
+ yield(["a","b"])
+end
+
+def call_three
+ yield(["a", "b", "c"])
+end
+
+def yield_with_splat(method_name = 'call_two')
+ send(method_name) { |*a| yield(*a) }
+end
+
+describe 'yield splat' do
+ it 'yields an array when block has only one argument' do
+ value = nil
+ yield_with_splat("call_one") { |a| value = a }
+ value.should == ["a"]
+ end
+
+ it 'yields an array when block as one argument and passed two' do
+ value = nil
+ yield_with_splat("call_two") { |a| value = a }
+ value.should == ["a", "b"]
+ end
+
+ it 'yields one value when block has two arguments and passed one' do
+ first_value = nil
+ second_value = nil
+ yield_with_splat("call_one") { |a,b| first_value = a; second_value = b }
+ first_value.should == "a"
+ second_value.should == nil
+ end
+
+ it 'yields two values when block has two arguments and passed two' do
+ first_value = nil
+ second_value = nil
+ yield_with_splat { |a,b| first_value = a; second_value = b }
+ first_value.should == "a"
+ second_value.should == "b"
+ end
+
+ it 'yields two values when block has two arguments and passed three' do
+ first_value = nil
+ second_value = nil
+ yield_with_splat("call_three") { |a,b| first_value = a; second_value = b }
+ first_value.should == "a"
+ second_value.should == "b"
+ end
+end
View
10 spec/regression/JRUBY-6892_drop_on_enumerator_oddity_spec.rb
@@ -0,0 +1,10 @@
+require 'rspec'
+
+describe "Enumerable#drop" do
+ context "when called on an Enumerator" do
+ let(:enumerator) { (1..10).to_a.each_slice(3)}
+ it "should behave as if it is called on an Enumerable" do
+ enumerator.drop(2).should == [[7,8,9],[10]]
+ end
+ end
+end
View
12 src/org/jruby/Main.java
@@ -393,11 +393,8 @@ private Status doCheckSyntax(Ruby runtime, InputStream in, String filename) thro
boolean status = checkStreamSyntax(runtime, in, filename);
// check other scripts specified on argv
- String[] argv = config.getArgv();
- if (argv.length > 0) {
- for (String arg : argv) {
- status = status && checkFileSyntax(runtime, arg);
- }
+ for (String arg : config.getArgv()) {
+ status = status && checkFileSyntax(runtime, arg);
}
return new Status(status ? 0 : -1);
@@ -446,10 +443,7 @@ private void doSetContextClassLoader(Ruby runtime) {
}
private void doProcessArguments(InputStream in) {
- String[] args = config.parseShebangOptions(in);
- if (args.length > 0) {
- config.processArguments(args);
- }
+ config.processArguments(config.parseShebangOptions(in));
}
private void doPrintProperties() {
View
44 src/org/jruby/Ruby.java
@@ -118,6 +118,7 @@
import org.jruby.runtime.scope.ManyVarsDynamicScope;
import org.jruby.threading.DaemonThreadFactory;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
import org.jruby.util.IOInputStream;
import org.jruby.util.IOOutputStream;
import org.jruby.util.JRubyClassLoader;
@@ -143,19 +144,7 @@
import java.net.BindException;
import java.nio.channels.ClosedChannelException;
import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.WeakHashMap;
+import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
@@ -164,6 +153,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
+import org.jruby.javasupport.proxy.JavaProxyClassFactory;
/**
* The Ruby object represents the top-level of a JRuby "instance" in a given VM.
@@ -1111,6 +1101,9 @@ private void init() {
// Initialize all the core classes
bootstrap();
+
+ // set up defined messages
+ initDefinedMessages();
irManager = new IRManager();
@@ -1161,6 +1154,14 @@ private void bootstrap() {
initExceptions();
}
+ private void initDefinedMessages() {
+ for (DefinedMessage definedMessage : DefinedMessage.values()) {
+ RubyString str = RubyString.newString(this, ByteList.create(definedMessage.getText()));
+ str.setFrozen(true);
+ definedMessages.put(definedMessage, str);
+ }
+ }
+
private void initRoot() {
boolean oneNine = is1_9();
// Bootstrap the top of the hierarchy
@@ -2695,6 +2696,15 @@ public void addBoundMethod(String className, String methodName, String rubyName)
return boundMethods;
}
+ public void setJavaProxyClassFactory(JavaProxyClassFactory factory) {
+ this.javaProxyClassFactory = factory;
+ }
+
+ public JavaProxyClassFactory getJavaProxyClassFactory() {
+ return javaProxyClassFactory;
+ }
+
+
public class CallTraceFuncHook extends EventHook {
private RubyProc traceFunc;
@@ -4209,6 +4219,10 @@ public void setFFI(FFI ffi) {
this.ffi = ffi;
}
+ public RubyString getDefinedMessage(DefinedMessage definedMessage) {
+ return definedMessages.get(definedMessage);
+ }
+
@Deprecated
public int getSafeLevel() {
return 0;
@@ -4463,4 +4477,8 @@ public void secure(int level) {
private ThreadLocal<Boolean> inRecursiveListOperation = new ThreadLocal<Boolean>();
private FFI ffi;
+
+ private JavaProxyClassFactory javaProxyClassFactory;
+
+ private EnumMap<DefinedMessage, RubyString> definedMessages = new EnumMap<DefinedMessage, RubyString>(DefinedMessage.class);
}
View
5 src/org/jruby/RubyEnumerable.java
@@ -281,7 +281,10 @@ public static IRubyObject drop(ThreadContext context, IRubyObject self, IRubyObj
public IRubyObject yield(ThreadContext context, IRubyObject arg) {
synchronized (result) {
if (i == 0) {
- result.append(arg);
+ // While iterating over an RubyEnumerator, "arg"
+ // gets overwritten by the new value, leading to JRUBY-6892.
+ // So call .dup() whenever appropriate.
+ result.append(arg.isImmediate() ? arg : arg.dup());
} else {
--i;
}
View
17 src/org/jruby/RubyString.java
@@ -1302,13 +1302,17 @@ public final RubyString cat(byte[] str, int beg, int len) {
// // rb_str_buf_append
public final RubyString cat19(RubyString str) {
ByteList other = str.value;
- int otherCr = cat(other.getUnsafeBytes(), other.getBegin(), other.getRealSize(),
- other.getEncoding(), str.getCodeRange());
+ int otherCr = cat19(other, str.getCodeRange());
infectBy(str);
str.setCodeRange(otherCr);
return this;
}
+ public final int cat19(ByteList other, int codeRange) {
+ return cat(other.getUnsafeBytes(), other.getBegin(), other.getRealSize(),
+ other.getEncoding(), codeRange);
+ }
+
public final RubyString cat(RubyString str) {
return cat(str.getByteList());
}
@@ -2543,6 +2547,15 @@ public RubyString append(IRubyObject other) {
}
public RubyString append19(IRubyObject other) {
+ if (other instanceof RubyFixnum) {
+ cat19(ConvertBytes.longToByteList(((RubyFixnum)other).getLongValue()), StringSupport.CR_7BIT);
+ return this;
+ } else if (other instanceof RubyFloat) {
+ return cat19((RubyString)((RubyFloat)other).to_s());
+ } else if (other instanceof RubySymbol) {
+ cat19(((RubySymbol)other).getBytes(), 0);
+ return this;
+ }
return cat19(other.convertToString());
}
View
18 src/org/jruby/RubySymbol.java
@@ -42,6 +42,7 @@
import static org.jruby.util.StringSupport.codeLength;
import static org.jruby.util.StringSupport.codePoint;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import org.jcodings.Encoding;
@@ -652,6 +653,7 @@ private static ByteList symbolBytesFromString(Ruby runtime, String internedSymbo
private final ReentrantLock tableLock = new ReentrantLock();
private volatile SymbolEntry[] symbolTable;
+ private final ConcurrentHashMap<ByteList, RubySymbol> bytelistTable = new ConcurrentHashMap<ByteList, RubySymbol>(100, 0.75f, Runtime.getRuntime().availableProcessors());
private int size;
private int threshold;
private final float loadFactor;
@@ -693,15 +695,27 @@ public RubySymbol getSymbol(String name) {
}
public RubySymbol getSymbol(ByteList bytes) {
+ RubySymbol symbol = bytelistTable.get(bytes);
+ if (symbol != null) return symbol;
+
String name = bytes.toString();
int hash = name.hashCode();
SymbolEntry[] table = symbolTable;
for (SymbolEntry e = getEntryFromTable(table, hash); e != null; e = e.next) {
- if (isSymbolMatch(name, hash, e)) return e.symbol;
+ if (isSymbolMatch(name, hash, e)) {
+ symbol = e.symbol;
+ break;
+ }
+ }
+
+ if (symbol == null) {
+ symbol = createSymbol(name, bytes, hash, table);
}
- return createSymbol(name, bytes, hash, table);
+ bytelistTable.put(bytes, symbol);
+
+ return symbol;
}
public RubySymbol fastGetSymbol(String internedName) {
View
6 src/org/jruby/ast/AndNode.java
@@ -34,12 +34,14 @@
import java.util.List;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Represents a && (and) operator.
@@ -96,11 +98,11 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
if (!context.runtime.is1_9()) {
return super.definition(runtime, context, self, aBlock);
} else {
- return EXPRESSION_BYTELIST;
+ return runtime.getDefinedMessage(DefinedMessage.EXPRESSION);
}
}
}
View
2  src/org/jruby/ast/ArgumentNode.java
@@ -60,7 +60,7 @@ public NodeType getNodeType() {
}
public Object accept(NodeVisitor visitor) {
- throw new RuntimeException("ArgumentNode should never be evaluated");
+ return null;
}
/**
View
6 src/org/jruby/ast/AssignableNode.java
@@ -31,6 +31,7 @@
package org.jruby.ast;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.types.IArityNode;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.Arity;
@@ -38,6 +39,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Base class of any node which can be assigned to.
@@ -81,7 +83,7 @@ public Arity getArity() {
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- return ASSIGNMENT_BYTELIST;
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ return runtime.getDefinedMessage(DefinedMessage.ASSIGNMENT);
}
}
View
6 src/org/jruby/ast/AttrAssignNode.java
@@ -33,6 +33,7 @@
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.evaluator.ASTInterpreter;
@@ -48,6 +49,7 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Node that represents an assignment of either an array element or attribute.
@@ -256,7 +258,7 @@ private IRubyObject otherAssign(Ruby runtime, ThreadContext context, IRubyObject
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
if (receiverNode.definition(runtime, context, self, aBlock) != null) {
try {
IRubyObject receiver = receiverNode.interpret(runtime, context, self, aBlock);
@@ -267,7 +269,7 @@ public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self
if (visibility != Visibility.PRIVATE &&
(visibility != Visibility.PROTECTED || metaClass.getRealClass().isInstance(self))) {
if (metaClass.isMethodBound(name, false)) {
- return ASTInterpreter.getArgumentDefinition(runtime, context, argsNode, ASSIGNMENT_BYTELIST, self, aBlock);
+ return ASTInterpreter.getArgumentDefinition(runtime, context, argsNode, runtime.getDefinedMessage(DefinedMessage.ASSIGNMENT), self, aBlock);
}
}
} catch (JumpException e) {
View
10 src/org/jruby/ast/BackRefNode.java
@@ -36,12 +36,14 @@
import org.jruby.Ruby;
import org.jruby.RubyMatchData;
import org.jruby.RubyRegexp;
+import org.jruby.RubyString;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Regexp back reference:
@@ -57,12 +59,12 @@
private final char type;
/** ByteList for the name of this backref global */
- private final ByteList nameByteList;
+ private final DefinedMessage definedMessage;
public BackRefNode(ISourcePosition position, int type) {
super(position);
this.type = (char) type;
- this.nameByteList = ByteList.create("$" + (char)type);
+ this.definedMessage = DefinedMessage.byText("$" + (char)type);
}
public NodeType getNodeType() {
@@ -110,11 +112,11 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
IRubyObject backref = context.getCurrentScope().getBackRef(runtime);
if (backref instanceof RubyMatchData) {
- return context.runtime.is1_9() ? GLOBAL_VARIABLE_BYTELIST : nameByteList;
+ return runtime.getDefinedMessage(runtime.is1_9() ? DefinedMessage.GLOBAL_VARIABLE : definedMessage);
}
return null;
}
View
6 src/org/jruby/ast/CallNoArgNode.java
@@ -34,6 +34,7 @@
import org.jruby.Ruby;
import org.jruby.RubyClass;
+import org.jruby.RubyString;
import org.jruby.exceptions.JumpException;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.javasupport.util.RuntimeHelpers;
@@ -69,8 +70,7 @@ public Node setIterNode(Node iterNode) {
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- ByteList definition = null;
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
if (getReceiverNode().definition(runtime, context, self, aBlock) != null) {
try {
IRubyObject receiver = getReceiverNode().interpret(runtime, context, self, aBlock);
@@ -79,6 +79,6 @@ public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self
}
}
- return definition;
+ return null;
}
}
View
6 src/org/jruby/ast/CallNode.java
@@ -37,6 +37,7 @@
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.evaluator.ASTInterpreter;
@@ -52,6 +53,7 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* A method or operator call.
@@ -171,7 +173,7 @@ public IRubyObject assign(Ruby runtime, ThreadContext context, IRubyObject self,
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
if (receiverNode.definition(runtime, context, self, aBlock) != null) {
try {
IRubyObject receiver = receiverNode.interpret(runtime, context, self, aBlock);
@@ -182,7 +184,7 @@ public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self
if (visibility != Visibility.PRIVATE &&
(visibility != Visibility.PROTECTED || metaClass.getRealClass().isInstance(self))) {
if (!method.isUndefined()) {
- return ASTInterpreter.getArgumentDefinition(runtime, context, getArgsNode(), METHOD_BYTELIST, self, aBlock);
+ return ASTInterpreter.getArgumentDefinition(runtime, context, getArgsNode(), context.runtime.getDefinedMessage(DefinedMessage.METHOD), self, aBlock);
}
}
} catch (JumpException excptn) {
View
11 src/org/jruby/ast/ClassVarNode.java
@@ -36,6 +36,7 @@
import org.jruby.MetaClass;
import org.jruby.Ruby;
import org.jruby.RubyModule;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.evaluator.ASTInterpreter;
@@ -44,6 +45,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Access to a class variable.
@@ -94,20 +96,19 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- //RubyModule module = context.getRubyClass();
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
RubyModule module = context.getCurrentScope().getStaticScope().getModule();
if (module == null && self.getMetaClass().isClassVarDefined(name)) {
- return CLASS_VARIABLE_BYTELIST;
+ return runtime.getDefinedMessage(DefinedMessage.CLASS_VARIABLE);
} else if (module.isClassVarDefined(name)) {
- return CLASS_VARIABLE_BYTELIST;
+ return runtime.getDefinedMessage(DefinedMessage.CLASS_VARIABLE);
}
IRubyObject attached = module.isSingleton() ? ((MetaClass)module).getAttached() : null;
if (attached instanceof RubyModule && ((RubyModule) attached).isClassVarDefined(name)) {
- return CLASS_VARIABLE_BYTELIST;
+ return runtime.getDefinedMessage(DefinedMessage.CLASS_VARIABLE);
}
return null;
View
9 src/org/jruby/ast/Colon2ConstNode.java
@@ -7,6 +7,7 @@
import org.jruby.Ruby;
import org.jruby.RubyModule;
+import org.jruby.RubyString;
import org.jruby.exceptions.JumpException;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.lexer.yacc.ISourcePosition;
@@ -14,6 +15,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
*
@@ -39,10 +41,13 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
IRubyObject lastError = context.getErrorInfo();
try {
- if (RuntimeHelpers.isModuleAndHasConstant(leftNode.interpret(runtime, context, self, aBlock), name)) return CONSTANT_BYTELIST;
+ if (RuntimeHelpers.isModuleAndHasConstant(
+ leftNode.interpret(runtime, context, self, aBlock), name)) {
+ return runtime.getDefinedMessage(DefinedMessage.CONSTANT);
+ }
} catch (JumpException e) {
// replace lastError
context.setErrorInfo(lastError);
View
3  src/org/jruby/ast/Colon2ImplicitNode.java
@@ -30,6 +30,7 @@
import org.jruby.Ruby;
import org.jruby.RubyModule;
+import org.jruby.RubyString;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
@@ -69,7 +70,7 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
* appear to be a ConstNode.
*/
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
assert false: "definition should not ever happen for Colon2ImplicitNode";
return null;
}
View
8 src/org/jruby/ast/Colon2MethodNode.java
@@ -6,6 +6,7 @@
package org.jruby.ast;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.exceptions.JumpException;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.lexer.yacc.ISourcePosition;
@@ -13,6 +14,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Represents a constant path which ends in a method (e.g. Foo::bar). Note: methods with
@@ -31,9 +33,11 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
try {
- if (hasMethod(leftNode.interpret(runtime, context, self, aBlock))) return METHOD_BYTELIST;
+ if (hasMethod(leftNode.interpret(runtime, context, self, aBlock))) {
+ return runtime.getDefinedMessage(DefinedMessage.METHOD);
+ }
} catch (JumpException e) {
}
View
8 src/org/jruby/ast/Colon3Node.java
@@ -35,6 +35,7 @@
import org.jruby.Ruby;
import org.jruby.RubyModule;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.exceptions.JumpException;
@@ -43,6 +44,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Global scope node (::FooBar). This is used to gain access to the global scope (that of the
@@ -100,14 +102,14 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
try {
RubyModule left = runtime.getObject();
if (hasConstant(left)) {
- return CONSTANT_BYTELIST;
+ return runtime.getDefinedMessage(DefinedMessage.CONSTANT);
} else if (hasMethod(left)) {
- return METHOD_BYTELIST;
+ return runtime.getDefinedMessage(DefinedMessage.METHOD);
}
} catch (JumpException excptn) {
}
View
6 src/org/jruby/ast/ConstNode.java
@@ -34,6 +34,7 @@
import java.util.List;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.ISourcePosition;
@@ -41,6 +42,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* The access to a Constant.
@@ -93,8 +95,8 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- return context.getConstantDefined(name) ? CONSTANT_BYTELIST : null;
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ return context.getConstantDefined(name) ? runtime.getDefinedMessage(DefinedMessage.CONSTANT) : null;
}
public IRubyObject getValue(ThreadContext context) {
View
36 src/org/jruby/ast/DNode.java
@@ -2,12 +2,17 @@
import org.jcodings.Encoding;
import org.jruby.Ruby;
+import org.jruby.RubyFixnum;
+import org.jruby.RubyFloat;
import org.jruby.RubyString;
+import org.jruby.RubySymbol;
+import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
import org.jruby.util.StringSupport;
/**
@@ -45,16 +50,29 @@ public boolean isSameEncoding(StrNode strNode) {
}
protected RubyString allocateString(Ruby runtime) {
- ByteList bytes = new ByteList();
-
- if (is19()) bytes.setEncoding(encoding);
+ RubyString string = RubyString.newString(runtime, new ByteList());
- return RubyString.newStringShared(runtime, bytes, StringSupport.CR_7BIT);
+ if (is19()) string.setEncoding(encoding);
+
+ return string;
}
public void appendToString(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock, RubyString string, Node node) {
- if (node instanceof StrNode && (!is19() || isSameEncoding((StrNode) node))) {
- string.getByteList().append(((StrNode) node).getValue());
+ if (node instanceof StrNode) {
+ StrNode strNode = (StrNode)node;
+ if (!is19() || isSameEncoding(strNode)) {
+ string.getByteList().append(strNode.getValue());
+ } else {
+ string.cat19(strNode.getValue(), strNode.getCodeRange());
+ }
+ } else if (node instanceof EvStrNode) {
+ EvStrNode evStrNode = (EvStrNode)node;
+
+ Node bodyNode = evStrNode.getBody();
+ if (bodyNode == null) return;
+
+ IRubyObject body = bodyNode.interpret(runtime, context, self, aBlock);
+ RuntimeHelpers.shortcutAppend(string, body);
} else if (is19()) {
string.append19(node.interpret(runtime, context, self, aBlock));
} else {
@@ -74,8 +92,8 @@ public RubyString buildDynamicString(Ruby runtime, ThreadContext context, IRubyO
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- ByteList definition = super.definition(runtime, context, self, aBlock);
- return is19() && definition == null ? EXPRESSION_BYTELIST : definition;
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ RubyString definition = super.definition(runtime, context, self, aBlock);
+ return is19() && definition == null ? runtime.getDefinedMessage(DefinedMessage.EXPRESSION) : definition;
}
}
View
6 src/org/jruby/ast/DSymbolNode.java
@@ -30,6 +30,7 @@
package org.jruby.ast;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.Block;
@@ -69,6 +70,9 @@ public Object accept(NodeVisitor visitor) {
@Override
public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- return runtime.newSymbol(super.interpret(runtime, context, self, aBlock).toString());
+ RubyString str = (RubyString)super.interpret(runtime, context, self, aBlock);
+ return runtime.is1_9() ?
+ str.intern19() :
+ str.intern();
}
}
View
8 src/org/jruby/ast/DVarNode.java
@@ -34,6 +34,7 @@
import java.util.List;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.ISourcePosition;
@@ -41,6 +42,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Access a dynamic variable (e.g. block scope local variable).
@@ -120,10 +122,10 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- ByteList definition = LOCAL_VARIABLE_BYTELIST;
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ RubyString definition = runtime.getDefinedMessage(DefinedMessage.LOCAL_VARIABLE);
if (!context.runtime.is1_9()) {
- definition = LOCAL_VARIABLE_IN_BLOCK_BYTELIST;
+ definition = runtime.getDefinedMessage(DefinedMessage.LOCAL_VARIABLE_IN_BLOCK);
}
return definition;
}
View
4 src/org/jruby/ast/DefinedNode.java
@@ -83,7 +83,7 @@ public Node getExpressionNode() {
@Override
public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- ByteList definition = expressionNode.definition(runtime, context, self, aBlock);
- return definition != null ? RubyString.newStringShared(runtime, definition) : runtime.getNil();
+ RubyString definition = expressionNode.definition(runtime, context, self, aBlock);
+ return definition != null ? definition : runtime.getNil();
}
}
View
12 src/org/jruby/ast/FCallNode.java
@@ -34,6 +34,7 @@
import java.util.List;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.evaluator.ASTInterpreter;
@@ -44,6 +45,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Represents a method call with self as an implicit receiver.
@@ -134,9 +136,15 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
if (self.getMetaClass().isMethodBound(getName(), false)) {
- return ASTInterpreter.getArgumentDefinition(runtime, context, getArgsNode(), METHOD_BYTELIST, self, aBlock);
+ return ASTInterpreter.getArgumentDefinition(
+ runtime,
+ context,
+ getArgsNode(),
+ runtime.getDefinedMessage(DefinedMessage.METHOD),
+ self,
+ aBlock);
}
return null;
View
6 src/org/jruby/ast/FalseNode.java
@@ -34,6 +34,7 @@
import java.util.List;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.types.IEqlNode;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
@@ -43,6 +44,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.DefinedMessage;
/**
* Represents a false literal.
@@ -81,8 +83,8 @@ public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject se
}
@Override
- public ByteList definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
- return FALSE_BYTELIST;
+ public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
+ return runtime.getDefinedMessage(DefinedMessage.FALSE);
}
public boolean eql(IRubyObject otherValue, ThreadContext context, Ruby runtime, IRubyObject self, Block aBlock) {
View
6 src/org/jruby/ast/GlobalVarNode.java
@@ -34,6 +34,7 @@
import java.util.List;
import org.jruby.Ruby;
+import org.jruby.RubyString;
import org.jruby.ast.types.INameNode;
import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.ISourcePosition;
@@ -41,6 +42,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;