[ruby/yarp] Convert constant pool entries to a string type in Java Loader

* Fixes https://github.com/ruby/yarp/issues/1389
* Fields of type `string` as kept as byte[].

https://github.com/ruby/yarp/commit/234c8f47c7
This commit is contained in:
Benoit Daloze 2023-09-14 18:52:17 +02:00 committed by git
parent 38e98cbb6a
commit c47608494f

View File

@ -9,6 +9,9 @@ module YARP
SERIALIZE_ONLY_SEMANTICS_FIELDS = ENV.fetch("YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS", false) SERIALIZE_ONLY_SEMANTICS_FIELDS = ENV.fetch("YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS", false)
JAVA_BACKEND = ENV["YARP_JAVA_BACKEND"] || "truffleruby"
JAVA_STRING_TYPE = JAVA_BACKEND == "jruby" ? "org.jruby.RubySymbol" : "String"
# This represents a field on a node. It contains all of the necessary # This represents a field on a node. It contains all of the necessary
# information to template out the code for that field. # information to template out the code for that field.
class Field class Field
@ -91,7 +94,7 @@ module YARP
end end
def java_type def java_type
"byte[]" JAVA_STRING_TYPE
end end
end end
@ -103,7 +106,7 @@ module YARP
end end
def java_type def java_type
"byte[]" JAVA_STRING_TYPE
end end
end end
@ -115,7 +118,7 @@ module YARP
end end
def java_type def java_type
"byte[][]" "#{JAVA_STRING_TYPE}[]"
end end
end end