10

Can someone please explain what the difference between ArrayList<?>, ArrayList and ArrayList<Object> is, and when to use each? Are they all same or does each have some different meaning at the implementation level?


Failed to build gem native extension ruby racer gem of different version

I copied the application from production and did bundle install to install all the missing gems that are in production version and not on my local machine.

Gem.lock file has the rubyracer version '0.10.1'. So when it tried to install this version using bundle install following error appeared.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/user/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb                                                                                                                                                                                                           
*** extconf.rb failed ***                                                                                                                                                                                                                                                      
Could not create Makefile due to some reason, probably lack of                                                                                                                                                                                                                 
necessary libraries and/or headers.  Check the mkmf.log file for more                                                                                                                                                                                                          
details.  You may need configuration options.                                                                                                                                                                                                                                  

Provided configuration options:                                                                                                                                                                                                                                                
        --with-opt-dir                                                                                                                                                                                                                                                         
        --without-opt-dir                                                                                                                                                                                                                                                      
        --with-opt-include                                                                                                                                                                                                                                                     
        --without-opt-include=${opt-dir}/include                                                                                                                                                                                                                               
        --with-opt-lib                                                                                                                                                                                                                                                         
        --without-opt-lib=${opt-dir}/lib                                                                                                                                                                                                                                       
        --with-make-prog                                                                                                                                                                                                                                                       
        --without-make-prog                                                                                                                                                                                                                                                    
        --srcdir=.                                                                                                                                                                                                                                                             
        --curdir                                                                                                                                                                                                                                                               
        --ruby=/home/user/.rvm/rubies/ruby-1.9.3-p392/bin/ruby                                                                                                                                                                                                               
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)                                                                                                                                                                                    


Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p392/gems/therubyracer-0.10.1 for inspection.                                                                                                                                                             
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p392/gems/therubyracer-0.10.1/ext/v8/gem_make.out      

I am not able to run the scaffolding commands on my production version of code from my local machine because of this error . Please help me out.

Can we edit the gemfile.lock to remove "therubyracer (0.10.1)" and then run the command generate scaffold and then place back the changes after my use of generate scaffold ?

EDIT :

 *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/vsadhu/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
extconf.rb:14:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)
4

2 に答える 2

19

ArrayList<Object>特にObjects のリストですArrayList<?>が、 は具体的な型が不明なリストです (つまり、 以外はリストに追加できませんnull)。リストのタイプが関係ない場合、たとえば、実行したい操作がリストのタイプに依存しない場合は、後者を使用します。例えば:

public static boolean isBigEnough(ArrayList<?> list) {
    return list.size() > 42;
}

これはすべて、ジェネリックのチュートリアルで説明されています (ワイルドカードのセクションを参照してください)。

最後に、ArrayList型パラメーターがないのは生の型です。これが許可されている唯一の理由は、Java バージョン 5 未満との下位互換性のためであり、可能な限り使用を控えてください。

于 2013-08-29T14:17:00.383 に答える
1

ArrayList<?>ArrayList「決定されるタイプを含むインスタンス」を意味します

ArrayListのクラスですArrayList

Anは、包含型ArrayList<Object>のインスタンスを意味します。ArrayListObject

これは、これ(およびその他)に関する良い記事になる可能性があるようです:http://docs.oracle.com/javase/tutorial/java/generics/types.html

于 2013-08-29T14:16:53.977 に答える