Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created September 19, 2011 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayosec/1225886 to your computer and use it in GitHub Desktop.
Save ayosec/1225886 to your computer and use it in GitHub Desktop.
Parsing...
pixels.mirah
Inferring types...
pixels.mirah:51: undefined local variable or method `value' for Annotation
String("JRubyMethod"):Mirah::AST::Annotation
def get(context:ThreadContext , arg:IRubyObject):IRubyObject
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
getRuntime.newFixnum @buffer.get(int(longValueFromObject(arg)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
end
^^^^^
Mirah::InternalCompilerError: undefined local variable or method `value' for Annotation
String("JRubyMethod"):Mirah::AST::Annotation
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:280
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:275
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:35
each at org/jruby/RubyArray.java:1603
each_with_index at org/jruby/RubyEnumerable.java:952
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:33
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:275
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:35
each at org/jruby/RubyArray.java:1603
each_with_index at org/jruby/RubyEnumerable.java:952
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:33
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:275
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/class.rb:110
define_type at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:93
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/class.rb:108
resolve_if at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast.rb:238
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/class.rb:104
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:275
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:35
each at org/jruby/RubyArray.java:1603
each_with_index at org/jruby/RubyEnumerable.java:952
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:33
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:275
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:270
resolve_if at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast.rb:238
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/ast/structure.rb:265
infer at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/typer/simple.rb:275
infer_asts at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/generator.rb:47
each at org/jruby/RubyArray.java:1603
infer_asts at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/generator.rb:47
generate at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/generator.rb:35
execute at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/commands/compile.rb:26
execute_base at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/commands/base.rb:41
catch at org/jruby/RubyKernel.java:1191
execute_base at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/commands/base.rb:38
execute at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah/commands/compile.rb:23
compile at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/lib/mirah.rb:40
(root) at /home/ayosec/.rvm/gems/jruby-1.6.4/gems/mirah-0.0.9-java/bin/mirahc:27
load at org/jruby/RubyKernel.java:1063
(root) at /home/ayosec/.rvm/gems/jruby-1.6.4/bin/mirahc:19
jruby-1.6.4 :001 > java_import "org.jchunkypng.Builder"
=> Java::OrgJchunkypng::Builder
jruby-1.6.4 :002 > Builder.init JRuby.runtime
NativeException: java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract int org.jruby.anno.JRubyMethod.required() (Found data of type class java.lang.String[1])
from sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java:56:in `generateException'
from sun/reflect/annotation/AnnotationInvocationHandler.java:74:in `invoke'
from $Proxy8:-1:in `required'
from org/jruby/anno/JavaMethodDescriptor.java:82:in `<init>'
from org/jruby/RubyModule.java:560:in `clump'
from org/jruby/anno/TypePopulator.java:51:in `populate'
from org/jruby/RubyModule.java:654:in `defineAnnotatedMethodsIndividually'
from org/jruby/RubyModule.java:542:in `defineAnnotatedMethods'
from org/jchunkypng/pixels.mirah:84:in `init'
from (irb):2:in `evaluate'
from org/jruby/RubyKernel.java:1088:in `eval'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/lib/ruby/1.8/irb.rb:158:in `eval_input'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1191:in `catch'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1191:in `catch'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/lib/ruby/1.8/irb.rb:70:in `start'
from /home/ayosec/.rvm/rubies/jruby-1.6.4/bin/irb:17:in `(root)'jruby-1.6.4 :003 > ayosec@rubies [jruby-1.6.4] ~/mirah/buildr/src/main/mirah$ ^C
package org.test;
import org.jruby.*
import org.jruby.anno.*
import org.jruby.runtime.*
import org.jruby.runtime.builtin.*
#import static org.jruby.RubyEnumerator.enumeratorize;
import java.nio.LongBuffer
class Pixels < RubyObject
def initialize(runtime:Ruby, klass:RubyClass)
super runtime, klass
end
$JRubyMethod["name" => "initialize"]
def initialize_allocated(arg:IRubyObject):IRubyObject
if arg.kind_of? RubyInteger
size = int(RubyInteger(arg).getLongValue())
@buffer = LongBuffer.allocate(size)
else
raise getRuntime.newArgumentError("An integer was expected")
end
self
end
$JRubyMethod["name" => ["length", "size"]]
def length(arg:IRubyObject):IRubyObject
getRuntime.newFixnum @buffer.limit
end
$JRubyMethod["name" => "each", "optional" => 1]
def each(context:ThreadContext, args:IRubyObject[], block:Block):IRubyObject
if block.isGiven
runtime = getRuntime
0.upto(@buffer.limit) do |index|
block.yield context, runtime.newFixnum(@buffer.get(index))
end
else
# return enumeratorize(context.getRuntime(), this, "each", args)
return getRuntime.getNil
end
self
end
$JRubyMethod["name" => ["[]", "get"], "required" => 1]
def get(context:ThreadContext , arg:IRubyObject):IRubyObject
getRuntime.newFixnum @buffer.get(int(longValueFromObject(arg)))
end
$JRubyMethod["name" => ["[]=", "put"], "required" => 1]
def set(context:ThreadContext, arg0:IRubyObject, arg1:IRubyObject):IRubyObject
@buffer.put int(longValueFromObject(arg0)), longValueFromObject(arg1)
arg1
end
private
def longValueFromObject(arg:IRubyObject):long
unless arg.kind_of?(RubyInteger)
raise getRuntime.newTypeError("can't convert #{arg.getMetaClass()} into Integer");
end
RubyInteger(arg).getLongValue
end
end
class FooBuilder
def self.init(runtime:Ruby):void
pixelClass = runtime.defineClass("Pixels", runtime.getObject) do |runtime, klass|
Pixels.new(runtime, klass);
end
pixelClass.defineAnnotatedMethods Pixels.class
pixelClass.includeModule runtime.getEnumerable
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment